Problem/Motivation
Currently the handling of the alt / title properties of file entities in file_entity_file_load()
doesn't take in account that there's also the Entity cache module which caches entities language agnostic.
Now if you fix the File Entity module with #2553067: Language option missing for token replacements to make the alt / title property replacement language aware (probably using Entity Translation) then using Entity cache will basically revert the fix by serving the cache, language agnostic, version.
So the alt / title properties will be stuck in whatever language was used to prime the Entity cache.
Proposed resolution
Use hook_entitycache_ENTITY_TYPE_load()
to re-run the alt / title property replacement in the current language whenever the entities are served by Entity cache.
To do so split the current replacement into a dedicated function (how about file_entity_set_title_alt_properties()
?) so it can be re-used in both hooks.
The attached patch does exactly this.
It also implements parts of the change here: #2553067: Language option missing for token replacements
Remaining tasks
Reviews needed.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
file_entity-integrate-with-entity-cache.patch | 2.2 KB | das-peter | |
Comments
Comment #2
das-peter CreditAttribution: das-peter at Cando commentedComment #3
purushotam.rai CreditAttribution: purushotam.rai as a volunteer and at QED42 commentedThis works for me. Thanks
Comment #4
joseph.olstadI also noticed this issue. See the approach I took (a small, fairely straightforward core patch)
#2835135: image formatter needs to handle alt/title from file entities on images for multi language support
I'm thinking of committing either the patch to file_entity by @David_Rothstein
#2473621: Alt and title text don't appear in the correct language when viewing a file in a language other than the current page language
OR
the one by @das-peter :
#2806081: translated Title and Alt text fix, use optionally with entitycache and entity_translation
different approaches , but both look good. I'm leaning towards the @David_Rothstein approach because it is maybe slightly simpler? not sure.
However, I haven't >yet< tested either of the last two approaches as we're still using the core patch I wrote.
Comment #5
joseph.olstadComment #6
joseph.olstadHmm, after reviewing further, now I may be leaning to the two @das-peter patches.
the one above
https://www.drupal.org/files/issues/file_entity-integrate-with-entity-ca...
AND
#2553067: Language option missing for token replacements
https://www.drupal.org/files/issues/file_entity-use-language-when-replac...
Comment #7
purushotam.rai CreditAttribution: purushotam.rai as a volunteer and at QED42 commented@joseph.olstad, for me also the patch gave positive results:
https://www.drupal.org/files/issues/file_entity-integrate-with-entity-ca...
Thanks
Comment #8
joseph.olstadIt's going in
Comment #10
joseph.olstadFor background info, see:
#2473621: Alt and title text don't appear in the correct language when viewing a file in a language other than the current page language
This is going into 7.x-3.x as well.
Comment #11
joseph.olstadComment #13
joseph.olstadComment #14
joseph.olstad