This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 18 replies, has 3 voices.

Last updated by Ricardo Alday 1 year, 5 months ago.

Assigned support staff: Ricardo Alday.

Author Posts
April 16, 2018 at 1:45 pm #1647088

francoP-4

Hello,
I have just installed and activated WPML media and the results is that on translated pages the img tag gets the src attribute removed or the field of src is replaced with the absolute image path. Moreover, it would not let me save the page. Disactivating the plugin now allows me to save the page, but I will have to fix all the pages with the damaged img tag.

Can you please help to get the plugin working correctly.

Regards
Franco

April 16, 2018 at 4:32 pm #1649517

Ankit

Hi Franco,

Thanks for contacting WPML support.

Could you please do following for me?

1. Deactivate all non-related wpml plugins and switch to default wordpress theme, check if similar issue still persists or not? If not, then please activate the deactivated plugins one by one and check if issue appears. If all the plugins are activated and issue is not appearing, activate your theme and check if issue appears.

This can be somewhat non-trivial task, so it will be better if you can perform this test on development/staging server of your website.

2. Also could you please confirm if the img tags are having external image as source or local image uploaded on website?

IMPORTANT: Please take database and file backup of your website before performing these steps, it may require in case something goes wrong.

April 17, 2018 at 10:18 am #1658196

francoP-4

Hi Ankit,

I have followed your instructions and even with all the plugins disabled (except for the WMPL set) it happens. That's how I can reproduced it systematically:

1. Create a new translation by clicking on the + in the page list

2. Overwrite (empty) content from main language. At this point I can read all the URLs are fine. Btw, most of URLs are relative, starting with /page-name or /wp-content/uploads/image-name

3. Save the page. All the URLs have either turned absolute or the src value has disappeared, such as <img id="u39_img" class="img" src="" />

I am on php 7.1, but no error is logged. It looks like a WPML media "standard" behaviour.

The URLs I am talking about are all internal to the website, haven't checked the external ones.

F.

April 17, 2018 at 10:48 am #1658990

Ankit

I would request you consider providing me with temporary access (wp-admin and FTP) to your site in order to be of better help.

You will find the needed fields for this below the comment area when you log in to leave your next reply (See attachment). The information you will enter is private which means only you and I can see and have access to it.

April 18, 2018 at 8:20 am #1670405

francoP-4

Hi,
the dev website I setup has no DNS and you have to change your hosts file to access it. Do you agree with that? If so, I will provide you with the admin access, etc. Otherwise I cannot give you access to test on a production website.
Regards
Franco

April 18, 2018 at 2:36 pm #1676374

Ricardo Alday

Hi Franco,

Ankit is not here today. I'll be taking over this ticket.
Sure, access to your dev site is fine. I'll enable the private fields below again.

Thanks,
Ricardo

April 19, 2018 at 10:29 pm #1706857

Ricardo Alday

Thanks and sorry for the late reply. As a workaround please change this line:
wp-content/plugins/wpml-media-translation/classes/images-translation/class-wpml-media-translated-images-update.php line# 57

From this:

if ( $translated_src !== $img['attributes']['src'] ) {

To this:

if ( $translated_src !== $img['attributes']['src'] && $translated_src != false) {

Let me know if that helps,
Ricardo

April 20, 2018 at 8:52 am #1718155

francoP-4

Hi Ricardo,

as I have performed the suggested change on the dev website, but there's little improvement: for the home page I just recreated the EN page from the FR, but after saving it many images have now the absolute path and the first one was even changed from grume-base.png to grume.png (as it was the case before already). The only improvement seem to be the images at the bottom, just before the js blocks, whereby the img of the kind <img id="u37_img" class="img" src="/wp-content/uploads/bt1_u36.png" /> are left untouched.

Regards
Franco

April 20, 2018 at 3:19 pm #1728294

Ricardo Alday

I can't see any posts now but for the pages that do have translations, i can see the images on both languages, for example:
hidden link and hidden link

Can you recreate the issue? If it's ok with you I would like to create a clone of your site using the Duplicator plugin for further debugging.

April 20, 2018 at 4:29 pm #1730564

francoP-4

Hi Ricardo,

my tests were mostly on the home page. Anyway, please go ahead and duplicate the website.

Regards
Franco

April 20, 2018 at 6:35 pm #1731878

Ricardo Alday

Right, your homepage displays your latest posts but you have not translated the posts into English nor German. If you translate the posts does the problem persist on your end?

April 21, 2018 at 7:54 am #1737083

francoP-4

By the way, the home page is accueil, not the posts page,I have now fixed it. I think it's the WPML media plugin that changes that. It happened already on the live site and we were blaming a collaborator, but here on the dev it was only me and you. Strange as it may appear, it must be the plugin, although the root cause may be somewhere else, I guess.

Regards

April 23, 2018 at 4:38 pm #1773765

Ricardo Alday

There is a known bug that will be fixed in the next update of WPML Media. The workaround is to edit the line in class-wpml-media-translated-images-update.php I referred to before.

How did you fix the pages?

April 24, 2018 at 4:50 am #1779165

francoP-4

Ricardo,
the problem is NOT fixed. What I corrected is the setting in theme - customise - static home page, in order to define the page accueil as the home page. The fact that the WPML Media plugin resets that (to the blog lisiting) is a significant problem per se, but not the purpose of this ticket.

Just delete permanently the EN page of accueil then:
1. Create a new translation of accueil by clicking from the + in the FR page list

2. Overwrite content from the FR language. At this point, beforfe saving, I can read all the image URLs in the src attributes are fine.

3. Save the page. All the URLs on the EN page have turned absolute. With the patch you sent the src attributes no longer disappear, but they still turn to absolute.

4. As an additional bug, the image grume-base.png is turned into grume.png ; how can that be??

April 24, 2018 at 4:19 pm #1793981

Ricardo Alday

Gotcha. I was able to replicate the issue on a cloned copy of your site I made on my local installation. The fact that the image url changes from relative to absolute on translations is expected because translated pages have different urls and an absolute path is needed.
The issue with the file changing names is not.
I tried to recreate the problem on a clean installation using the same theme, WPBakery Page Builder, WPML, and the same WPML add-ons that you have but it didn't come up.
The file name remains the same on translations, only the url changes from relative to absolute.

I did notice that you are using older versions of WPML and its add-ons so I suggest you update and try to replicate the issue. Create a new page in French, add some images the same way you added in the homepage and then translate this new page.

Let me know if the problem comes up again.
Ricardo

The topic ‘[Closed] wpml media removes src from translated pages’ is closed to new replies.