Hi,
I am trying to implement responsive images on a new site. I have this setup in config.php
:
'thumbs' => [
'srcsets' => [
'default' => [
'300w' => ['width' => 300],
'600w' => ['width' => 600],
'900w' => ['width' => 900],
'1200w' => ['width' => 1200],
'1800w' => ['width' => 1800],
'2300w' => ['width' => 2300],
'2880w' => ['width' => 2880],
],
'avif' => [
'300w' => ['width' => 300, 'format' => 'avif'],
'600w' => ['width' => 600, 'format' => 'avif'],
'900w' => ['width' => 900, 'format' => 'avif'],
'1200w' => ['width' => 1200, 'format' => 'avif'],
'1800w' => ['width' => 1800, 'format' => 'avif'],
'2300w' => ['width' => 2300, 'format' => 'avif'],
'2880w' => ['width' => 2880, 'format' => 'avif'],
],
'webp' => [
'300w' => ['width' => 300, 'format' => 'webp'],
'600w' => ['width' => 600, 'format' => 'webp'],
'900w' => ['width' => 900, 'format' => 'webp'],
'1200w' => ['width' => 1200, 'format' => 'webp'],
'1800w' => ['width' => 1800, 'format' => 'webp'],
'2300w' => ['width' => 2300, 'format' => 'webp'],
'2880w' => ['width' => 2880, 'format' => 'webp'],
],
]
],
And the following on my page (using an image from assets for now):
<?php
$image = asset('assets/img/logo.png');
?>
<picture>
<source
srcset="<?= $image->srcset('avif') ?>"
sizes="(min-width: 640px) 500px, 80vw"
type="image/avif"
>
<source
srcset="<?= $image->srcset('webp') ?>"
sizes="(min-width: 640px) 500px, 80vw"
type="image/webp"
>
<img
class="h-auto w-[80vw] sm:max-w-[500px] text-center"
alt="Description"
src="<?= $image->resize(1200)->url() ?>"
srcset="<?= $image->srcset() ?>"
sizes="(min-width: 640px) 500px, 80vw"
width="<?= $image->resize(2880)->width() ?>"
height="<?= $image->resize(2880)->height() ?>"
>
</picture>
This is generating the resized image (png) and webp images just fine, but the avif images that are generated are all just copies of the original .png at original size - there is no resizing or file type conversion. It is changing the extension to .avif and adding the size (e.g. -300x), but the file isn’t changing.
I have asked the hosts and they have said GD is running on the server. If anyone has any thoughts that would be super
Mike