Option to select image format in filter argument
zlobec opened this issue · 3 comments
zlobec commented
Hi,
since webp is not supported on Apple devices (Safari), it would be nice if the filter would be able to pass the image format for each request. Like |resize(100,100,{format:'webp'})
.
This way it would be possible to output webp and also a fallback image format, like this:
<picture>
<source srcset="img/awesomeWebPImage.webp" type="image/webp">
<source srcset="img/creakyOldJPEG.jpg" type="image/jpeg">
<img src="img/creakyOldJPEG.jpg" alt="Alt Text!">
</picture>
Regard,
Darjan
bradietilley commented
You should be able to do that already, for example:
<picture>
<source srcset="{{ 'path/to/image.png' | resize(100, 100, { format: 'webp'}) }}" type="image/webp">
<source srcset="{{ 'path/to/image.png' | resize(100, 100, { format: 'jpg'}) }}" type="image/jpeg">
...
</picture>
or is that not what you're after?
zlobec commented
Yes. This is exactly what I am looking for.
It's not exactly clear in the documentation about the format argument, so I would suggest adding this example to the documentation.
bradietilley commented
Added the format modifier, thanks