Skip Navigation

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

Problem:
The client was trying to display a translated image field (a taxonomy field) with the Return Format set as "Image URL". While it worked in the original language, the translation returned the image ID as a string instead of the image URL.
Solution:
We checked the issue and found that the order in the English term did not match the default language term. We corrected this discrepancy. We then asked the client to verify if the English post now displays the image URL as expected.
If this solution does not seem relevant to your issue, please feel free to open a new support ticket with us.

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 4 replies, has 2 voices.

Last updated by Osama Mersal 1 year, 2 months ago.

Assisted by: Osama Mersal.

Author Posts
December 11, 2023 at 12:29 pm #15036957

Gregory

I am trying to: display a translated image field (it is a taxonomy field, in case this is somehow related to the issue).
We have set the Return Format as "Image URL". This workds in the original language. However, in the translation, the image ID is being returned as a string.

Link to a page where the issue can be seen: hidden link (the top image is set in a post taxonomy field).

I expected to see: The image url.

Instead, I got: The image ID in string format (in the translation - it works in the primary language).

December 12, 2023 at 10:06 am #15043987

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for contacting WPML forums support. I'll be glad to help you today.

1) Please let me know how this image is added to the page. Do you use custom code/function?

Also, please let me know the translation mode you use for this field group.

2) It's not related to the issue, but according to your Debug.info, the WP memory limit needs to be increased. PHP memory is fine, but WordPress uses 40Mb as default. The minimum requirements for WPML are 128 MB. (Kindly check this page https://wpml.org/home/minimum-requirements/)

You can increase it by adding the following code in your wp-config.php file right before the /* That's all, stop editing! Happy publishing. */ line:

/* Memory Limit */
define('WP_MEMORY_LIMIT', '256M');
define( 'WP_MAX_MEMORY_LIMIT', '256M');

Best regards,
Osama

December 12, 2023 at 10:33 am #15044249

Gregory

Hi Osama,

Thank you for your response.

1. We are using the following code, according to the ACF documentation (hidden link):

$entry_cities = get_the_terms( get_the_ID(), 'entry_city' );
if( $entry_cities ) {
foreach( $entry_cities as $term ) {
if (get_field('city_image', $term)) {
$image_url = get_field('city_image', $term);
}
}
}

We are not aware of there being a way to display the field other than with code.
The translation mode is "Same fields across languages".

2. Thank you for the suggestion; we have added the code to wp-config.php.

Best Regards,
Sociality

December 12, 2023 at 10:35 am #15044253

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for your update. I would need to look closely at your site, so I would need to request temporary access (WP-Admin and FTP)
Preferably to a test site where the problem has been replicated.

Your answer will be private, meaning only you and I can access it.

❌ Please backup your database and website ❌

✙ I would need your permission to de-activate and re-activate the Plugins and the Theme and change configurations on the site. This is also a reason the backup is critical.

✙ I also need your permission to take a local copy of your site to debug the issue without affecting your live site.

Best regards,
Osama

December 12, 2023 at 11:27 am #15045021

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for the access details. I checked the issue and noticed that the order in the English term doesn't match the default language term, so I changed it. (Kindly check the attached screenshot)

Please check if the English post works as expected. (hidden link)

Best regards,
Osama

2023-12-12_13-24-03.jpg
December 12, 2023 at 11:44 am #15045163

Gregory

Thank you ver much, it now retrieves he field correctly.
I am unsure as to why the order would affect the field, but, in any case, it now works.

Once again, many thanks!

Sociality