- Issue created by @erwangel
- 🇩🇪Germany stefan.korn Jossgrund
@erwangel: Thanks for your review of the module and bringing up this interesting points.
Currently the module is only targeting the source field of a media with image source type.
The thumbnail is a base field of any media entity. Testing this a bit, it would work with thumbnail too if changing the code to allow for configuring thumbnail with link to parent entity checkbox and modifying the output to support this too.
This would also allow to use it on remote video too.
And thinking some more about this, I suppose it could work for any image field in any media entity.
So if changing the approach I guess supporting any image field in any media entity would be the desired result. But this is quite a bigger rework of the code. I need to work a bit more on this.
Another point:
I am not sure what image_private media source is. This is not coming from core I suppose. Is it a module that is providing this or maybe a custom implementation on your end?
But if the approach I described above would be feasible, maybe we can get rid of the media sources check all together. - Assigned to stefan.korn
- Status changed to Needs work
6 months ago 4:32pm 19 May 2024 -
stefan.korn →
committed 2a8088eb on 8.x-1.x
Issue #3411452 by erwangel, stefan.korn: make it work with any image...
-
stefan.korn →
committed 2a8088eb on 8.x-1.x
- 🇩🇪Germany stefan.korn Jossgrund
@erwangel: I committed solution to the dev branch which should do the following:
- work with any image field on any media entity type, including thumbnail
would be great if you can test this if you find the time.
- Status changed to Needs review
6 months ago 5:06pm 19 May 2024 - 🇫🇷France erwangel
"Private images" appeared as an extra media type in my settings after the upgrade from Drupal 7 to 9. And I think one has to create this type if he wants to store images in a Private file system path (see settings @
/admin/config/media/file-system
). The image field (field_media_image) of media image type doesn't permit to chose the storage on uploading; you have to define it in settings (see @/admin/structure/media/manage/image/fields/media.image.field_media_image
). So if for some of your images you want a private storage (outside of site root) you have to define a new media type (p.e. private_images) and set the appropriate storage. You can still access private images for display through styles but not directly by their url.I'll come back in a few days to test the new dev version. Thank you for making it.
- 🇫🇷France erwangel
The new dev looks fine. It works on all my media types. I had a look in your code and it seems the right approach. However it produces the default language links as pointed in issue 3316244 (url not translated) 🐛 Generated URL of parent entity is not translated Postponed: needs info . Have a look there; I commented it and proposed a working solution.
Also I noticed that $formatters are defined in InitialSettingsService as ['image', 'responsive_image']. I tested and it's okay with both of them, but what about other formatters that modules may add (I have blazy and colorbox, but also image_field_tokens, I don't know where the last comes from perhaps token module). I understand we can't plan ahead what formatters may be available there. Perhaps make it clear in documentation and presentation page that the module acts only on core 'image' and 'responsive_image'.
Blazy is widely used and it may be worth having some kind of compatibility. I tried to add 'blazy' in the $formatters array, the 'link to parent' option appeared in formatter's settings but it had no effect on display. I was not surprised as Blazy has it's own 'link to' called 'Media switcher' but it's mostly for switching to colorbox or other lightboxes supported by this module and anyhaw it lacks an option to 'link to the parent'.
I think we can consider the $sources issue fixed and if you think a solution to make the module compatible with other formaters is possible, perhaps open an other issue.
- Status changed to RTBC
6 months ago 7:59am 21 May 2024