Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Dynamic loading images in picture with srcset

Started by Pedro M 5 years ago · 1 replies · 602 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 Andy Miller, 1 week ago
0 143 1 week ago
General · by lynbor, 1 month ago
3 459 2 weeks ago
General · by lynbor, 3 weeks ago
7 596 2 weeks ago
General · by Harry, 2 weeks ago
0 180 2 weeks ago
General · by Old Man Umby, 1 month ago
2 322 4 weeks ago