If condition for SVG images

Hi!

i would like to modify the output of my images. currently all images are converted to ‘webp’.
however, this should not happen with uploaded ‘svg’ images. this is why i would like to output svg images differently with an if condition.
can you tell me how such an if condition could look like? thank you very much!

You could use one of those $file methods:

so something like

if($yourImage->extension() === 'svg') {
// Do something
} else {
// convert to webp
}

Or you turn it around and convert only PNGs or JPEGs to webp. I am not quite sure what the exact output of extension() is (uppercase, lowercase…) maybe output it once to see what exactly you get when calling that method.

1 Like

thank you very much! you saved my day!

1 Like

There’s also isResizable()

if($yourImage->isResizable()) {
  // Convert to webp
}
1 Like