awcodes / filament-curator

A media picker plugin for Filament Panels.
MIT License
343 stars 89 forks source link

Division by zero when using `.svg` files #275

Closed leo-unglaub closed 1 year ago

leo-unglaub commented 1 year ago

Hey, i just noticed an exception in your extension. If an .svg file is used then the code does not know the size and fails with a division by zero. The following line in vendor/awcodes/filament-curator/src/View/Components/Glider.php:118 is the problem:

$height = floor($width * ($this->media->height / $this->media->width));

As you can see, if $this->media->with is unknown, it fails.

Thanks and greetings

awcodes commented 1 year ago

Thanks. Will dig into it this weekend.

awcodes commented 1 year ago

I'm thinking this should throw an exception since you are trying to use an svg image with srcsets.

leo-unglaub commented 1 year ago

But svg is a valid format in srcset.

awcodes commented 1 year ago

It doesn't make sense to use srcset with svg. Srcset loads different physically sized images. Svg isn't saved at different sizes, there is no need since it is vector based. So you'd load one svg and control its size with css.