Use SVG Images with glide

Hi, I'm trying to use glide with svg Image. I add this to twill.php 'glide' => [ 'original_media_for_extensions' => ['svg'], 'default_params' => [ 'fm' => 'png', 'q' => '100', 'auto' => 'compress,format', 'fit' => 'min', ], 'lqip_default_params' => [ 'fm' => 'webp', 'auto' => 'compress', 'blur' => 100, 'dpr' => 1, ], ], With this I can see in backend the correct image (PIC 1) So now i'm trying to use it in frontend $world_image = $page ->imageObjects('world_image', 'default') ->map(function ($media) use ($page) { return @TwillImage::make($page, 'world_image', $media)->crop('default'); })->toArray(); foreach ($world_image as $k => $image) { if (isset($image['image']['src'])) { $data['img'] = $image['image']; break; } When I try this with SVG image i Have this error (with cron and uncropped image)
DivisionByZeroError thrown with message "Division by zero" Stacktrace: #57 DivisionByZeroError in /Users/mikmella/Sites/vendor/area17/twill-image/src/Services/MediaSource.php:276 #56 A17\Twill\Image\Services\MediaSource:aspectRatio in /Users/mikmella/Sites/vendor/area17/twill-image/src/Services/MediaSource.php:315 #55 A17\Twill\Image\Services\MediaSource:toArray in /Users/mikmella/Sites//vendor/area17/twill-image/src/Models/Image.php:281 ...
If I use a png or jpg image all works fine! Someone can help me? Thank you
5 Replies
ifox
ifox2y ago
Hi @Sami if you're looking to render as SVG, I don't think Twill image is suitable or necessary, as it will be trying to compute responsive sets. I think you can submit an issue to twill-image though, as we should take original_media_for_extension into consideration to avoid this error.
Sami
Sami2y ago
Hi @ifox. Thanks for your tip. Will write it down for my future coding so I'm ready when the situation comes. Until then I'm tagging @Kormi so he can also read this answer.
ifox
ifox2y ago
oops sorry I tagged the wrong person, thanks @Sami
Kormi
Kormi2y ago
Thank You @Sami So How can I get url of an uploaded svg?
ifox
ifox2y ago
ImageService::getRawUrl($media->uuid)
Want results from more Discord servers?
Add your server