What's the recommended way to convert and output WebP with Kirby?

I would like to ask the community and experienced Kirby developers, how they deal with WebP in Kirby and what best practices they recommend?

I took a look at the documentation of Kirby which shows, WebP as file format is supported, yet to my understanding, it doesn’t have a built in way to already convert like JPG uploads to WebP. That’s where the plugins seem to come in.

I found two plugins: Kirby 3 WebP by HashandSalt and Kirby 3 WebP by Felix Haeberle.

My goal would be to be able to upload JPG/PNG and get them converted to WebP additionally, but still be able to define my HTML picture tags manually and choose to output WebP and original file format seized fallbacks. Like using the parameters on image() and url() or something similar to choose the file format. Yet, looking at those two plugins, I don’t see how that would be possible.

Additionally, at some point the same question will come up with the AFIV format.

The Hash&Salt plugin has several methods that you can use to pick the right format. The webp images are auto-generated on upload.

The plugin also has a ->toWebp() file method you can use on images if they were not uploaded and it will convert them on the fly. The snippet built into the plugin does this check too. This is useful if the plugin has been added to a site with existing images, or if someone manually uploads an image via FTP since the upload hook wont have been triggered in that case.

Thanks a lot for your helpful inputs.

Any of you ever tried this one too?

Found that in one of the Kirby Kosmos emails when I looked whether there is an equivalent solution for AVIF. This one seems to do both, AVIF and WebP.