sal0max / grav-plugin-shortcode-gallery-plusplus

A Shortcode extension to add sweet galleries with a lightbox to your Grav website.
MIT License
33 stars 8 forks source link

Optimize page loading: indicate 2 images #12

Closed Fazarel closed 2 years ago

Fazarel commented 3 years ago

Suggestion for enhancement.

In order to optimize the page loading, allow to indicate 2 images: a small one and a large one. Or define a nomenclature to use 2 images (for example image.jpg and image_small.jpg in the same folder). The objective being a result in html as in this example:

<a href="large.jpg" class="glightbox">
  <img src="small.jpg" alt="image" />
</a>

In addition GLightbox allows the use of videos. Being able to specify 2 files would offer the possibility of an image in the gallery that links to a video in GLightbox.

If I develop a solution I will post it. For now I submit this suggestion for consideration...

sal0max commented 3 years ago

Yeah, it would improve performance and I already thought about it. And I'm aware of how this is done in glightbox. However, I couldn't find a way to do it in my plugin, without altering the syntax.

The idea of this plugin is to just wrap some [gallery] bbcode around existing images. I don't want other tags to be needed or having the existing image bbcodes altered. This way, it is a drop-in replacement for existing image listings.

Processing of image code is done in Grav core. All my plugin gets from this shortcode:

![Alt 3](photo-1487260211189-670c54da558d.jpg "Title 3")
![Alt 4](photo-1500239038240-9b3b8bac73c3.jpg "Title 4")

via Shortcode core is this:

</p>
<img title="Title 3" alt="Alt 3" src="/user/pages/demo/02.gallery-plusplus/photo-1487260211189-670c54da558d.jpg" />
<img title="Title 4" alt="Alt 4" src="/user/pages/demo/02.gallery-plusplus/photo-1500239038240-9b3b8bac73c3.jpg" />
</p>

It is pre-rendered html. No chance for me to apply something like this in twig

{{ page.media['sample-image.jpg'].resize(400, 200).html()|raw }}

to it.

So, there is no way to automatically add thumbnail size images. And as stated: I don't want the user to bother adding a second image manually.

If you've got a clever idea how to achieve this, I'd love to hear it. 👍

sal0max commented 2 years ago

Solved with https://github.com/sal0max/grav-plugin-shortcode-gallery-plusplus/pull/16