WPML

Overview of the Issue

You will notice that the main URL of one of your languages is also used on the images of your translated languages.

The images will still display correctly throughout the languages.

Still, you may encounter CORS (opens in a new tab) issues in some cases, which will translate into the image not showing.

This problem will only happen if you use different domains per language.

Workaround

This issue is fixed. Updating to the latest version solves it on your site, so you only need this workaround if you can’t update yet.

Please make a full backup of your site before proceeding:

  1. Locate and edit the following file: wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-image-translate.php
  2. Locate this code:
    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 ) {
  3. Add the following code right after  if ( $attachment_translation ) { :
    do_action( 'wpml_switch_language', $language );
  4. Save the changes.
  5. Please follow one of the following methods:

Method 1:

  • Install and activate WPML Media translation
  • Go to WPMLMedia Translation
  • Locate one of the problematic images
  • edit one of the translations
  • Make a small edit to the translated image’s description
  • Save the changes

Method 2:

  • Go to WPMLSettings
  • Scroll down until the section “Translate Link Target”
  • Click the “Apply” Button
  • Wait until the process finishes.

All known issues

Still Seeing This Issue?

If updating doesn’t fix it, ask a support question and we’ll look into it with you.