I want to provide the most optimized image version as possible by default without ignoring older browsers. That’s why I created the following code:
<?php if($image = $article->image()): ?>
<?php echo $image->thumb([
[ 'width' => 300, 'height' => 200, 'quality' => 80, 'format' => 'avif'],
[ 'width' => 300, 'height' => 200, 'quality' => 80, 'format' => 'webp'],
[ 'width' => 300, 'height' => 200, 'quality' => 80, 'format' => 'jpg']
])->html(); ?>
<?php endif ?>
With this code I just get the original image in full size instead of a thumb.
If I use this code instead I get a small .webp image, which is also the desired output but then no alternative image format is prepared:
<?php if($image = $article->image()): ?>
<?php echo $image->thumb([ 'width' => 300, 'height' => 200, 'quality' => 80, 'format' => 'webp' ])->html(); ?>
<?php endif ?>
Did I understand something wrong or is the code not correct?
I am testing the Kirby version 3.6.0 Alpha 3 and I have the following code in my config.php:
'thumbs' => [
'presets' => [
'default' => [
['width' => 1024, 'quality' => 80, 'format' => 'avif'],
['width' => 1024, 'quality' => 80, 'format' => 'webp'],
['width' => 1024, 'quality' => 80, 'format' => 'jpg']
]
],
'srcsets' => [
'default' => [
'800w' => ['width' => 800, 'quality' => 80, 'format' => 'avif'],
'800w' => ['width' => 800, 'quality' => 80, 'format' => 'webp'],
'800w' => ['width' => 800, 'quality' => 80, 'format' => 'jpg'],
'1024w' => ['width' => 1024, 'quality' => 80, 'format' => 'avif'],
'1024w' => ['width' => 1024, 'quality' => 80, 'format' => 'webp'],
'1024w' => ['width' => 1024, 'quality' => 80, 'format' => 'jpg'],
'1440w' => ['width' => 1440, 'quality' => 80, 'format' => 'avif'],
'1440w' => ['width' => 1440, 'quality' => 80, 'format' => 'webp'],
'1440w' => ['width' => 1440, 'quality' => 80, 'format' => 'jpg'],
'2048w' => ['width' => 2048, 'quality' => 80, 'format' => 'avif'],
'2048w' => ['width' => 2048, 'quality' => 80, 'format' => 'webp'],
'2048w' => ['width' => 2048, 'quality' => 80, 'format' => 'jpg']
]
]
],