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 thread is resolved. Here is a description of the problem and solution.

Problem:
using different image source by code

Solution:
There is not a built-in function in WPML and requires some custom coding in order to be achieved.

You can use a constant provided from our API and do the trick. https://wpml.org/documentation/support/wpml-coding-api/

You can adapt the code to suit your needs:

<?php if(ICL_LANGUAGE_CODE == 'en'){?>
<img src="picture for English" />
<?php }elseif(ICL_LANGUAGE_CODE == 'fr'){ ?>
<img src="picture for French" />
<?php }else{ ?>
<img src="picture for any other language that had not been specified" />
<?php } ?>

This topic contains 2 replies, has 2 voices.

Last updated by gregorK-3 2 years, 10 months ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
September 24, 2016 at 4:19 pm #1098658

gregorK-3

Hi

So I'm using
y

<div class="featured-ribbon">
				<img src="<em><u>hidden link</u></em>" alt="" title="" />
			</div>

to show featured ribbon on Featured images. As this code is inserted in theme file, i would like to know if there is a chance to set this multilanguage?
To show another png for another language.

Thank you

September 26, 2016 at 4:28 am #1099247

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hi there,

Thank you for contacting WPML support.

Unfortunately, this is not a built-in function in WPML and requires some custom coding in order to be achieved.

You can use a constant provided from our API and do the trick. https://wpml.org/documentation/support/wpml-coding-api/

You can adapt the code to suit your needs:

<?php if(ICL_LANGUAGE_CODE == 'en'){?>
<img src="picture for English" />
<?php }elseif(ICL_LANGUAGE_CODE == 'fr'){ ?>
<img src="picture for French" />
<?php }else{ ?>
<img src="picture for any other language that had not been specified" />
<?php } ?>

Please let me know if that helps you.

Thanks

September 26, 2016 at 11:29 am #1099935

gregorK-3

Brilliant!