Skip to content Skip to sidebar

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

Problem:
You need to change the image source (src) on a fixed banner loaded with a custom plugin, with a different image per language.
Solution:
1. Update your plugin with the following code:

$image_default = plugin_dir_url(__FILE__) . 'cmd_jobs/config/svs_Fixed_ban4_EL.jpg';<br /><br />/* Register image URL for translation */<br />do_action(<br />    'wpml_register_single_string',<br />    'svs-plugin',<br />    'banner_image_url',<br />    $image_default<br />);<br /><br />/* Retrieve translated image URL */<br />$svs_image_Banner = apply_filters(<br />    'wpml_translate_single_string',<br />    $image_default,<br />    'svs-plugin',<br />    'banner_image_url'<br />);

2. Navigate to WPML >> Theme and plugins localization, select your plugin, and press the “Scan selected components for strings” button.
3. Go to WPML >> String Translation.
4. Translate the 'banner_image_url' string by replacing it with the image URL for each language (e.g., EN image URL).
This approach allows WPML to load a different image URL per language without hardcoding multiple variables.
For more details, refer to the following documentation:

If this solution does not apply to your case, or if it seems outdated, we recommend opening a new support ticket. We also 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.

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

Last updated by soultanaS 3 months, 3 weeks ago.

Assisted by: Noman.

Author Posts
December 20, 2025 at 10:27 am #17679742

soultanaS

How can i change image (src) on fixed banner where loaded with custom plugin?
I site hidden link on bottom left on screen i load with custom plugin fixed banner with image.
I wont to have other image src per language.
I upload the screen snapshot.

December 20, 2025 at 10:34 am #17679781

soultanaS

I wait human support.
How can i change image (src) on fixed banner where loaded with custom plugin?

December 21, 2025 at 12:57 pm #17680533

Noman

Hi,

Thank you for contacting WPML Support. If the image is added via the plugin’s options page, you should be able to translate it by following the below steps:

1. Go to WPML >> String Translation
2. Open the “Not seeing strings that you are looking for?” section and press the “Admin texts translation” link.
3. Search for the image URL and enable its translation.
4. Go to the WPML >> String Translation page again and add the translated image URL as translation and see if this resolves the issue.

Here is a doc for more details:
https://wpml.org/documentation/getting-started-guide/string-translation/finding-strings-that-dont-appear-on-the-string-translation-page/#register-admin-and-setting-strings-for-translation

If the image URL is hardcoded in the plugin code, it needs to be wrapped in a gettext function. After that, it will appear in WPML >> String Translation and you can translate it per language. For example, use `__( 'image url, 'text-domain' )` and this will make the URL appear in WPML >> String Translation.

Here’s more information about the gettext function: https://wpml.org/documentation/support/how-to-use-gettext/

Kindly let me know how the image is added (via plugin settings or hardcoded in the plugin), so we can proceed accordingly.

Thank you

Admin texts translation.jpg
December 22, 2025 at 10:38 am #17681767

soultanaS

Thanks for your answer.
I searched in admin text and nothing found, maybe because the image link is hardcoded.

Here is the php code that i use to load the banner:
$svs_image_Banner = plugin_dir_url( __FILE__ ) . "cmd_jobs/config/" . "svs_Fixed_ban4_EL.jpg";
$svs_image_Banner_EN = plugin_dir_url( __FILE__ ) . "cmd_jobs/config/" . "svs_Fixed_ban4_EN.jpg";

$fixedHtmlban .= '';
$fixedHtmlban .= '';
$fixedHtmlban .= '
';

Witch change must do to wmpl see the image URL?

Thanks.

December 22, 2025 at 10:42 am #17681768

soultanaS

i upload image with the load code.
Thanks.

image_banner.png
December 22, 2025 at 5:39 pm #17683082

Noman

Thanks for the additional details. Could you please try to follow the below steps:

1. Update the plugin as follows:

$image_default = plugin_dir_url(__FILE__) . 'cmd_jobs/config/svs_Fixed_ban4_EL.jpg';

/* Register image URL for translation */
do_action(
    'wpml_register_single_string',
    'svs-plugin',
    'banner_image_url',
    $image_default
);

/* Retrieve translated image URL */
$svs_image_Banner = apply_filters(
    'wpml_translate_single_string',
    $image_default,
    'svs-plugin',
    'banner_image_url'
);

2. Go to WPML >> Theme and plugins localization page, select your plugin and press the “Scan selected components for strings” button.
3. Go to WPML >> String Translation
4. Translate the banner_image_url string by replacing it with the image URL for each language (e.g. EN image URL).

This way, WPML will load a different image URL per language without hardcoding multiple variables.

Here are docs for more details.
https://wpml.org/wpml-hook/wpml_register_single_string/
https://wpml.org/wpml-hook/wpml_translate_single_string/

I tested it at my test site and it works correctly. Could you please try and let me know how it goes.

Thank you

image url tranlsaiton.jpg
image url trasnlation frontend.jpg
image url trasnlation frontend 1.jpg
December 22, 2025 at 9:13 pm #17683410
soultanaS

I added the code and i do the scan on my plugin.
Now the banner_image_url exist on string translation, but the language that found is English and NOT el (greek) wich is the default wpml language.
This happens for all string translations!
This is wrong because the actual strings is greek.
Why?

New threads created by Noman and linked to this one are listed below:

https://wpml.org/forums/topic/wrong-source-language-assigned-to-the-strings/

string_tranlation_02.png
string_tranlation_01.png
December 23, 2025 at 10:01 am #17684231

Noman

Glad to hear the image URL is available for translation now.

For wrong source language problems, it’s a different issue and will be handled separately as per our support policy. I've created a new ticket for this at: https://wpml.org/forums/topic/wrong-source-language-assigned-to-the-strings/

If the image translation issue is solved, please mark this ticket as resolved and we will continue working on the above ticket for it.

Thank you for your cooperation

December 23, 2025 at 12:53 pm #17684732

soultanaS

My issue is resolved.
I add new source links per language for my banner.

Thanks.