abwebdevelopers/oc-imageresize-plugin

Option to select image format in filter argument

zlobec opened this issue · 3 comments

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

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?

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.

Added the format modifier, thanks