Skip to content
Grav 2.0 is officially stable. Read the announcement →
General

Dynamic loading images in picture with srcset

Started by Pedro M 5 years ago · 1 replies · 427 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 Jerry Hunt, 4 days ago
2 133 1 day ago
General · by pamtbaau, 1 day ago
1 93 1 day ago
General · by Andy Miller, 2 days ago
0 77 2 days ago
General · by Marcel, 12 months ago
6 386 5 days ago
General · by Duc , 6 days ago
3 72 6 days ago