Srcset() and animated gif

Hello everyone,

I’m developing a little one-page and I have an image grid on it. To meet the current optimization tips, I’ve set up a srcset() to get the best image according to the screen size, all automatically generated by Kirby and it’s awesome!

The concern is that this image grid contains animated gifs and these lose their animation when resized.

Here is the code in question :

<img class="object-cover w-full rounded-t" width="<?= $image->width() ?>" height="<?= $image->height() ?>" src="<?= $image->url() ?>" srcset="<?= $image->srcset([ '375w' => [width' => 305,], '768w' => [width' => 375,], '1336w' => [width' => 500,], '1500w' => [width' => 750,]]); ?>" alt="<?= $image->alt() ?> ">".

Is there a solution to this problem? Or should I think about not publishing animated gifs?

Thanks a lot!

Hey welcome to the forum!

Try switching the thumbs driver to ImageMagick by setting the config option. As i recall, the default of GD cannot handle animated gifs.

I can also highly reccomend running the source gifs through Compress of Die before uploading to the panel, which to my knowledge is the most effective optimiser for them.

1 Like

Thank you for the welcome, and your answer!
It’s perfect, the gif is animated again. :ok_hand:

I’ll also check Compress Or Die, thanks for the tip!

One answer, one solution.
The magic of this forum I love you guys! :smiley:

Your welcome :slight_smile: