- 🇪🇸Spain javier_rey
This has also happened to me in a Drupal 10.4.4.
Tested it at https://simplytest.me/Steps to reproduce the error:
- Add a language to the web, in this case it will be English (default) and Spanish.
- In the language configuration, indicate that in English the prefix will be “en” and in Spanish it will be “es” (admin/config/regional/language/detection/url)
- Using the content type “basic page”, mark it as translatable and add an image media type field (not translatable)
- Mark as translatable also the media type “image”.
- Create 2 nodes in English, add an image to them and translate them into Spanish.
Now comes the problem:
- Create a view that shows the content type “basic page”.
- Add the image field with the format “thumbnail (important, with the other formats it works fine)”.
- Check the “link to content” option in the image field.
- When checking the English view, both images point to the corresponding nodes in English:
- https://master-teaibnpl96czl1tjspp5qwvhrsw7quru.tugboatqa.com/en/node/1
- https://master-teaibnpl96czl1tjspp5qwvhrsw7quru.tugboatqa.com/en/node/2
- But if we switch to Spanish, the 2 images point to the English node.
- https://master-teaibnpl96czl1tjspp5qwvhrsw7quru.tugboatqa.com/en/node/1 (should be /es/node/1)
- https://master-teaibnpl96czl1tjspp5qwvhrsw7quru.tugboatqa.com/en/node/2 (should be /es/node/2)
So the problem seems to be that when selecting the thumbnail formatter, it is not picking up the correct language of the content it has to link to.
- First commit to issue fork.
- 🇮🇳India KumudB Ahmedabad
Improved Entity Translation Handling
In Drupal 8.1, entity translation handling was still evolving. The language negotiation and rendering system had some inconsistencies in cases where an untranslatable field (image) was being used in translated content.
In Drupal 11.x, the entity rendering system has improved, ensuring that links generated in untranslated fields respect the active page language.
Changes in ImageFormatter::viewElements()The issue in Drupal 8.1 was that viewElements() used LANGCODE_DEFAULT, which caused links to always point to the original entity language.
In Drupal 11.x, the rendering correctly respects the current entity translation.
Field Translation System FixesEarlier Drupal versions required making the image field translatable as a workaround.
In Drupal 11.x, this is no longer required because entity rendering now properly resolves translation context for non-translatable fields.