Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Dynamic loading images in picture with srcset

Started by Pedro M 5 years ago · 1 replies · 661 views
5 years ago

Is there anyway to load dynamically webp or jpeg images in picture HTML tag depending whether file exists in same folder?

For example if you have two images with the same name, one with webp extension and the other with jpeg extension. It would be possible load them in source srcset in picture tag?

Thanks

5 years ago

@pmoreno, That's not build-in, but can be created in Twig by |filter()|array-ing the image collection of a page.

You can then access the resulting array and create the picture element.

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 1 day ago
2 41 18 hours ago
General · by Hanns Mattes, 1 week ago
0 121 1 week ago
General · by Karmalakas, 1 week ago
2 185 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 235 3 weeks ago
General · by Dima, 4 weeks ago
1 211 4 weeks ago