Problem/Motivation
Currently it is not possible to fully "translate" image file field. It is possible to translate only Image file (different files for different translations) OR only "Alt" and "Title" attributes. If you try to translate both (image file and it's attributes) - it doesn't work correctly.
Symptoms and steps to reproduce
- Allow image field translation and select "File" in Translatable elements section.
- Translate a node that has image field:
- Upload new image for the translation
- Translate image title attribute
- Translate image alt attribute
Result
Uploaded image file overwrites all language versions of the node. This can be seen perfectly clear inside node__[image_field] table after translation of a node with "translated" image is saved.
The expected behavior is to update only the translated version of the node with new file and it's new attributes.
However this feature will work partially in two cases:
- If you leave "Alt" and "Title" attributes blank, then you'll be able to upload different images for each translation.
- If you set Translatable elements section to only "Alt" and "Title", everything will work as expected. In this case an image will have different Alt and Title attributes for each language, however the actual image file will always be the same.
Interestingly, the generic file field is NOT affected by this issue. Translated nodes can have different versions of files uploaded. Only the image field is affected by this issue.
Proposed resolution
Allow uploading different language versions of image files the same way as generic files.
Remaining tasks
Find out why this does not work and create a patch.
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#5 | wrong-data.png | 155.66 KB | SiliconMind |
#3 | image-field3.png | 4.21 KB | SiliconMind |
image-field2.png | 4.1 KB | SiliconMind |
Comments
Comment #1
SiliconMind CreditAttribution: SiliconMind commentedAdded inline images.
Comment #2
SiliconMind CreditAttribution: SiliconMind commentedFixed language-content tag
Comment #3
SiliconMind CreditAttribution: SiliconMind commentedIt turns out that it is possible to have different image files for each translation BUT only if "Alt" and "Title" attributes are left blank. Updating issue description.
Any clues why this is happening?
Comment #4
SiliconMind CreditAttribution: SiliconMind commentedComment Removed.
Once again fooled by virtually undebugable Entity class.
Comment #5
SiliconMind CreditAttribution: SiliconMind commentedThe problem seems to be that
Node::values
holds correct data butNode::fields
holds broken data. They don't match and the data that is saved comes fromNode::fields
array.This image shows kint dump of a node just before it gets saved with ContentEntityDatabaseStorage::doSaveFieldItems().
Below is the fragment of
ContentEntityDatabaseStorage::doSaveFieldItems()
:Comment #6
Jose Reyero CreditAttribution: Jose Reyero commentedComment #7
matsbla CreditAttribution: matsbla commentedI tested this again now in D8 beta9, and seems like this is no longer an issue! :)