Display .webp but download .jpg

I’m working on a page with an enormous amount of images. They are all to be displayed on a single page and by clicking on them they should be downloaded. I’m using the kirby3-webp plugin by felix haeberle to convert the images into very very small webp’s that are being displayed on the site. But I’d like the downloadable image to be the .jpg that was initially uploaded in the panel. Is this somehow possible?

webp is supported by Kirby for a while now. You should not need a plugin.

  • Upload all images in their native format (most likely jpg)
  • Display the image as webp in the img-tag
  • Wrap the image in a link to the image as jpg

Display the image as webp in the img-tag

I’d still have to upload both the .jpg and the .webp version in the backend, right? This makes it sound like I can just upload the .jpg and it will automatically converted by using the img-tag??

No, just upload JPG format from panel and render WEBP format from frontend like that:

<?= $image->thumb(['width' => 800, 'format' => 'webp']) ?>

or

<img src="<?= $image->thumb(['width' => 800, 'format' => 'webp'])->url() ?>"> alt="">
1 Like