Type()=='gif' isnt exist ahh? any other way to detect a gif?

Hi!
I try to detect if the file that has been uploaded is a gif or an image.
Since I resize the images in srcset - I would like to cancel the srcset for gifs.
I edited the image.php file and inserted before the srcset an If statement:

<?php if($block->type()=='gif'): ?>
    srcset='...'

But it seems that this function doesn’t really work.

any suggestion how can I detect a gif?

thanks a lot!

You shouldn’t check for $block->type(), because that’s always ‘image’.

Default image block also doesn’t generate the srcset - kirby/image.php at main · getkirby/kirby · GitHub - so you are probably overwriting something else?

Either way, you want something like $block->image()->toFile()->extension() === 'gif' or so.

1 Like

Thanks!
works perfectly :pray: