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

Add `loading` attribute to thumbnail `<img>` tags #28

Closed aricooperdavis closed 2 years ago

aricooperdavis commented 2 years ago

The <img> tag's loading attribute specifies when the client's browser should start load the images.

Grav has a global site setting (as of yet undocumented, but noted in the changelog) that allows site admins to specify what the value of this attribute should be. Twig's .loading action reads this setting and adds the appropraite attribute to the <img> tag. This commit just adds this .loading twig action when the thumbnails are generated.

I don't know much about how browsers interpret the loading attribute, but I assume that for very large galleries that extend significantly past the viewport this might improve performance.

Thanks for the excellent plugin 👍

sal0max commented 2 years ago

Thanks for the kind words and for this pull request! Great catch!

However, one question before I merge: As this is a new option with 1.7, this will probably not be backwards compatible with 1.6, right? In that case, the grav dependency version in the blueprints.yaml has to be changed accordingly.

aricooperdavis commented 2 years ago

Good point! I don't think the config lookup worked properly until 1.7.4 (see Grav issue #3912) so I've updated the blueprints.yaml dependency to that release.