Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Add support for Media Image and Video
Comment | File | Size | Author |
---|---|---|---|
#27 | lightgallery-media_support-3204181-27.patch | 5.31 KB | Kosa Ilma |
#8 | lightgallery-media_support-3204181-8.patch | 5.28 KB | phjou |
#7 | lightgallery-media_support-3204181-7.patch | 5.13 KB | phjou |
Issue fork lightgallery-3204181
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- issue/lightgallery-3204181-3204181-media_support_image_video_remotevideo changes, plain diff MR !15 / changes, plain diff MR !14
- olivierh65-8.x-1.x-patch-83822 changes, plain diff MR !3 / changes, plain diff MR !1
- olivierh65-8.x-1.x-patch-24762 changes, plain diff MR !2
- 8.x-1.x compare
- media_image_local-video compare
Comments
Comment #5
phjouJUst tried the patch, it work good for me on D9 thanks!
Comment #6
phjouComment #7
phjouJust found the issue that the configured image styles were not used. Patch attached to support them.
Comment #8
phjouJust added the support for remote_video that was missing. Patch attached.
Comment #13
phjouNot a big fan of the random thing for the ID. Why not using the clean_id twig filter?
https://www.drupal.org/docs/theming-drupal/twig-in-drupal/filters-modify...
Comment #14
phjouMoreover, I think my approach should be reconsidered to be more generic. It is based on the media from core but the formatter will not work with a custom media type.
Instead of testing the bundle, I would use a configuration of the formatter (image, remote video, local video) and then if it's possible to pick the field that is supposed to contain the image/video. Or if anyone has a better idea to make it work with a custom media.
Comment #15
olivierh65 CreditAttribution: olivierh65 as a volunteer commentedWhen using Views to display multiple albums (multiple contents with a media field with multiple elements), templates/lightgallery.html.twig is called sequentially for each album. It is therefore necessary to distinguish each album, otherwise, all videos of each album have the same id (video1, video2, ...) and therefore when viewing, it is no longer possible to display the right video (from what I found, always the videos of the first album).
The use of the random number allows to distinguish simply (not beautiful, but effective!) each series.
I saw in the twig variables, a variable id that seems to be different for each series, but I have not checked how this id is constituted.
In the options, if the use of the random number is redibitory, it is possible to :
- either check that the id transmitted to twig is unique in all series,
- or modify lightgallery-views-style.html.twig to add an index for each series.
Comment #16
phjouI am not against adding an ID but more the way it is generated. Changing it to use the "clean_id" filter should work as well.
Comment #17
olivierh65 CreditAttribution: olivierh65 as a volunteer commentedFrom what I have read and from the tests I have done,
clean_id does not generate a unique id, but modifies the string to be a valid id.
There should be a filter that calls \Drupal\Component\Utility\Html::getUniqueId. There is an issue on this topic (https://www.drupal.org/project/drupal/issues/3115445) to implement a Twig clean_unique_id filter.
Comment #18
olivierh65 CreditAttribution: olivierh65 as a volunteer commentedI think the best solution is to use the id variable present in Twig.
Looking in the lightgallery code, in lightgallery_views.theme.inc :
I modify to use this value.
Comment #20
hussainwebI just merged the latest 8.x-1.x in this branch so that I can test it.
Comment #21
hussainwebThe changes work except for one thing in my case. I had to slightly change the TWIG template to make a video thumbnail clickable (local video). This could be because of my theme and so I am not committing the changes to the branch but I wonder if anyone else saw that. This is the change I made to the corresponding template.
Line 29:
Changes to:
This is as per the HTML structure used for image thumbnails. The main relevant change is the addition of
<div class="field-content">
Comment #22
hussainwebComment #27
Kosa Ilma CreditAttribution: Kosa Ilma at Brainsum commentedUsing the patch from #8 on D10 upgrade preparation with Upgrade Status module I get:
Call to deprecated function file_create_url(). Deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the appropriate method on \Drupal\Core\File\FileUrlGeneratorInterface instead.
Here is the patch.
Comment #29
paulrad CreditAttribution: paulrad at DevBranch, Drupal Ukraine Community commentedSlightly improved MR !15, made the formatter compatible with view fields, media items visible, etc.