Hi,
I changed to Kirby Version 3.9.1 and I have the following problem.
If I use srcset I get the expected format conversion and the proper srcset. If I try to use a template srcsets in the config, it doesn’t work.
<picture class="<?php if($src_dark):?>img_light<?php endif ?>">
<source srcset="<?= $block->image()->toFile()->srcset([
'400w' => ['width' => 400, 'format' => 'webp'],
'800w' => ['width' => 800, 'format' => 'webp'],
'1200w' => ['width' => 1200, 'format' => 'webp']
]) ?> " alt="<?= $alt ?>" type="image/webp">
<source srcset="<?= $block->image()->toFile()->srcsets('avif') ?>" alt="<?= $alt ?>" type="image/avif">
<img src="<?= $src ?>" alt="<?= $alt ?>">
</picture>
The first (web) Version works this way. The second (avif) doesn’t work.
My config looks like this:
'thumbs' => [
'quality' => 80,
'presets' => [
'default' => ['width' => 704],
'thumb' => ['width' => 46, 'height' => 46, 'crop' => true],
'preview' => ['width' => 250, 'height' => 250, 'crop' => true],
],
'srcsets' => [
'default' => [
'300w' => ['width' => 300],
'600w' => ['width' => 600],
'900w' => ['width' => 900],
'1200w' => ['width' => 1200],
'1800w' => ['width' => 1800]
],
'avif' => [
'1200w' => ['width' => 1200, 'format' => 'avif'],
'1800w' => ['width' => 1800, 'format' => 'avif']
],
'webp' => [
'1200w' => ['width' => 1200, 'format' => 'webp'],
'1800w' => ['width' => 1800, 'format' => 'webp']
],
]
],
The presets are accessible, the srcsets not.
Is there something I have to do differently?
If I dump: $block->image()->toFile() it is of class Kirby\Cms\File Object and it is an image object.
If I dump: $block->image()->toFile()->srcsets(‘avif’) it is of class Kirby\Cms\Field Object and empty.
Thanks in advance,
Simon