Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:

The main URL of one of your languages is also used on the images of your translated languages in the separate domain mode.

Solution:

Check the workaround below.

Relevant Documentation:

https://wpml.org/errata/wrong-url-on-translated-media-files-when-using-a-different-domain-per-language/

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.

Tagged: ,

This topic contains 6 replies, has 2 voices.

Last updated by edouardR-2 1 year, 8 months ago.

Assisted by: Christopher Amirian.

Author Posts
May 15, 2023 at 11:24 am

edouardR-2

Image URLs are retrieved from the original language domain instead of the second language domain on the translated page.

Imaged are created using native WordPress editor image block.

May 15, 2023 at 1:08 pm
May 15, 2023 at 1:18 pm
May 15, 2023 at 2:34 pm #13648885

edouardR-2

Re,
The migration is complete.

May 15, 2023 at 3:53 pm #13649647

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Thank you very much, I asked for a second opinion and will get back to you as soon as I have an answer.

May 16, 2023 at 7:54 am #13652975

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

The issue is reported to the development team.

To explain why you see some images take the original domain and some are not, it is because the domain is save when the image is uploaded. So if you uploaded an image in the original domain, it will show everywhere with the original domain.

There is a temporary workaround:

- Enable/Install WPML Media plugin.
- Go to wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-image-translate.php
- Add the code below:

do_action( 'wpml_switch_language', $language );

- Rigth after:

	public function get_translated_image( $attachment_id, $language, $size = null ) {
		$image_url              = '';
		$attachment             = new WPML_Post_Element( $attachment_id, $this->sitepress );
		$attachment_translation = $attachment->get_translation( $language );

		if ( $attachment_translation ) {

- So the result should be:

public function get_translated_image( $attachment_id, $language, $size = null ) {
    $image_url              = '';
    $attachment             = new WPML_Post_Element( $attachment_id, $this->sitepress );
    $attachment_translation = $attachment->get_translation( $language );
 
    if ( $attachment_translation ) {
do_action( 'wpml_switch_language', $language );

- Then try to edit the article that has the image (In its original language) by adding a character in the title, for example.
- Save the changes
- Update translations
- Go to WPML > Media Translation and save one of the images.

That should do the trick.

Thanks.

May 16, 2023 at 1:30 pm #13656817

edouardR-2

Hello,
Thanks for your fast reply.

1. "So if you uploaded an image in the original domain, it will show everywhere with the original domain." ==> sorry but it is not the case, just make the test and you'll notice it. It just bugs on some images on this site. I have other sites under WPML and it works perfectly fine.

2. I tried to installed WPML Media. So I added the plug-in OGTS installer on my site. But when I activate it, it does not work. I can not active it. There is a bug.
Is it possible to activate OGTS Installer when others WPML Media plug-in are activated ? FYI:other plug-in are disabled, excepted woo-commerce and WPML...

May 17, 2023 at 6:03 am #13660581

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

Thank you for your answer. As we did have a scenario like yours it worths to try and see ethe solution given there works for you or not.

YOu do not need to install the OTGS intaller.

Please keep WPML Multilingual CMS plugin enabled and follow the steps below:

- IMPORTANT STEP! Create a backup of your website. Or better approach will be to test this on a copy/staging version of the website to avoid any disruption of a live website.
- Go to "WordPress Dashboard > Plugins > Add new > Commercial (tab)".
- In the list select the WPM Media Translation plugin.
- At the bottom of the table select the "Activate" checkbox and click download.
- That should install the plugin and after that do the changes mentioned int he steps before.

Thanks.

May 17, 2023 at 11:30 am #13663621

edouardR-2

My issue is resolved now. Thanks a lot !