Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Dynamic loading images in picture with srcset

Started by Pedro M 5 years ago · 1 replies · 572 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 jeremycherfas, 1 week ago
5 192 37 minutes ago
General · by lynbor, 6 days ago
2 128 3 days ago
General · by Old Man Umby, 1 week ago
1 103 1 week ago
General · by Sebastian, 2 weeks ago
1 127 2 weeks ago
General · by Andy Miller, 3 weeks ago
0 251 3 weeks ago