Skip to content Skip to sidebar

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

Problem:
The client is experiencing an issue with WPML Media Translation where the 'Save media translation' button remains inactive, and despite adding Name, Caption, and Alt text to a different file, the translated image does not appear, but the English image does.
Solution:
We recommend using the

apply_filters('wpml_object_id', $mediaID, 'attachment', true);

function to ensure that the media ID is correctly translated, which should resolve the issue with the inactive button and the incorrect display of images. Here is a step-by-step guide:
1. Retrieve the original media ID and URL.
2. Use the

apply_filters

function to get the translated media ID.
3. If the original media ID does not match the translated media ID, update the media URL and ID to the translated ones.
4. Verify that the translated media appears correctly in place of the English image.

If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket at WPML support forum for further assistance.

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 15 replies, has 1 voice.

Last updated by johnH-55 6 months ago.

Assisted by: Andreas W..

Author Posts
March 7, 2025 at 7:12 pm #16789763

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

My apologies, but I am not sure how to assist you on this matter.

I asked you for access to your site and provided a test site for recreating the issue but I did not receive access and you did not try to recreate the issue on the test site.

Which step would you like us to take so that I can assist you?

March 11, 2025 at 8:59 pm #16804160

johnH-55

Thank you Andres. I was able to resolve problem by using

apply_filters('wpml_object_id', $mediaID, 'attachment', true);

like

$mediaURL = $attributes['mediaURL'] ?? '';
$mediaID = $attributes['mediaID'] ?? '';
Library\Helpers\Media::validateMediaURLByMediaID($mediaURL, $mediaID); //temporary debug

// WPML: get translated mediaID
$translatedMediaID = apply_filters('wpml_object_id', $mediaID, 'attachment', true);
if ($mediaID != $translatedMediaID) {
$mediaURL = wp_get_attachment_url($translatedMediaID);
$mediaID = $translatedMediaID;
}

But still I cant explain why my old code worked with mediaURL IF I insert regular image block with same image.