Problem/Motivation
If you use the thumbnail formatter for a media item and use the option »Link image to« to link to the entity or the media item itself, the link always point to the original language of the entity or the media item. In a multilingual environment the user is loosing the current language by clicking on the link.
Proposed resolution
I adapt the provided solution on 2798977 to the MediaThumbnailFormatter to consider current content language.
Remaining tasks
It would be nice to merge all kind of related issues and provide a fix in one of next releases.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | drupal-missing-language-handling-in-MediaThumbnailFormatter-2961404-23.patch | 1.85 KB | rwam |
| #17 | 2961404-17.patch | 3.31 KB | naresh_bavaskar |
| #15 | interdiff-10-15.txt | 3.15 KB | naresh_bavaskar |
| #15 | 2961404-15.patch | 4.9 KB | naresh_bavaskar |
| #10 | interdiff_2961404_9-10.txt | 805 bytes | ankithashetty |
Comments
Comment #2
rwam commentedComment #3
borisson_We should add a test similar to the one added in #2798977: Wrong language handling in ImageFormatter when linking to entity as well.
Comment #5
chr.fritschAdding the #DrupalEurope tag for the Friday contribution sprint
Comment #6
nuezComment #9
enrocean167 commentedI don't know what is the better approach, but here is a patch with the same solution as in https://www.drupal.org/project/drupal/issues/2645922
Comment #10
ankithashettyJust fixed the custom commands failure in #9, thanks!
Comment #11
agoradesign commented#10 works for me (tried with 9.1.7)
Comment #12
quietone commentedSetting NW for tests.
Comment #13
agoradesign commentedadded #3089216: Media Thumbnail Formatter doesn't translate the title attribute correctly as related issue, as it also deals with translation problems on this formatter plugin
Comment #14
naresh_bavaskarComment #15
naresh_bavaskarAdded Tests, Please review.... (Initial test case might need some changes)
Comment #16
ajv009 commentedThanks @naresh_bavaskar for the tests. LGTM
Applies without any problem on 8.9.x
But someone with a better experience in writing tests for core should take a final look :)
Comment #17
naresh_bavaskarFailed PHPUnit test cases - testing
Comment #18
naresh_bavaskarSomething goes wrong while running Functional test cases, The Problem described in the ticket description its not able to reproducing on chromedriver testcases.
while phpunit browser output without fixing issue:
fr/node/{node_id}instead of/node/{node_id}Comment #23
rwam commentedChanges in https://www.drupal.org/project/drupal/issues/3255887 break the initial patch after updating our site to Drupal 9.5.0 so I've adapted the solution from #17 which work well on 9.5.x. I'm not familiar with testing so feel free to contribute or update the tests.
Comment #25
proweb.ua commented#23 work.
Drupal 10.3.6
Comment #26
atul_ghate commentedI am not able to reproduce this issue on Drupal 11.x. The steps I followed to reproduce are as below:
1.Clone Drupal 11.x and enable the Language and Content Translation modules.
2.Change the Manage Display settings for the media type and select the Thumbnail formatter with the Link to entity option enabled.
3.Create a Media type (image) and enable translation for it. Add an image with an English translation, then add a translation for another
language for the same media image
4.Add this media image to an Article node.
5.When I click on the image, it redirects me to the correct language version of the node.
Please let me know if there is anything I am missing.