Skip to content

Commit 2631026

Browse files
authored
Don't attempt to resize SVG images
1 parent bbc4193 commit 2631026

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

app/Uploads/ImageResizer.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ public function resizeToThumbnailUrl(
6666
bool $keepRatio = false,
6767
bool $shouldCreate = false
6868
): ?string {
69+
// Do not attempt to resize SVGs, return the raw value always.
70+
if ($this->isSvg($image)) {
71+
return $this->storage->getPublicUrl($image->path);
72+
}
73+
6974
// Do not resize GIF images where we're not cropping
7075
if ($keepRatio && $this->isGif($image)) {
7176
return $this->storage->getPublicUrl($image->path);
@@ -226,6 +231,14 @@ protected function isGif(Image $image): bool
226231
return $this->getExtension($image) === 'gif';
227232
}
228233

234+
/**
235+
* Checks if the image is a svg. Returns true if it is, else false.
236+
*/
237+
protected function isSvg(Image $image): bool
238+
{
239+
return $this->getExtension($image) === 'svg';
240+
}
241+
229242
/**
230243
* Get the extension for the given image, normalised to lower-case.
231244
*/

0 commit comments

Comments
 (0)