Dynamic loading images in picture with srcset

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

@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.