New to kirby, we choose this CMS for it’s flexibility and low server print, for a project with a low carbon indice.
In this way, Webp image would be a good choice to reduce global pages weight, but it seems not so easy to implement.
We plan to use this plugin : https://github.com/HashandSalt/kirby3-webp
All images source will be uploaded in panel in jpeg/png format.
Related images to texts are called like this :
<?php if($image = $page->cover()->toFile()): ?> <img src="<?= $image->url() ?>" alt=""> <?php endif ?>
<?php if($image = $page->visualhead()->toFile()): ?> <img src="<?= $image->resize(600)->url() ?>" alt=""> <?php endif ?>
But what would be the best way to serve webp image in front to build something like this :
<picture> <source srcset="my-image.webp" type="image/webp"> <img src="my-image.png" alt="Visual"> </picture>
Thank you for your help.