Skip to content

Commit

Permalink
Don't attempt to resize SVG images
Browse files Browse the repository at this point in the history
  • Loading branch information
tjone270 authored Jan 16, 2025
1 parent bbc4193 commit 2631026
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/Uploads/ImageResizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public function resizeToThumbnailUrl(
bool $keepRatio = false,
bool $shouldCreate = false
): ?string {
// Do not attempt to resize SVGs, return the raw value always.
if ($this->isSvg($image)) {
return $this->storage->getPublicUrl($image->path);
}

// Do not resize GIF images where we're not cropping
if ($keepRatio && $this->isGif($image)) {
return $this->storage->getPublicUrl($image->path);
Expand Down Expand Up @@ -226,6 +231,14 @@ protected function isGif(Image $image): bool
return $this->getExtension($image) === 'gif';
}

/**
* Checks if the image is a svg. Returns true if it is, else false.
*/
protected function isSvg(Image $image): bool
{
return $this->getExtension($image) === 'svg';
}

/**
* Get the extension for the given image, normalised to lower-case.
*/
Expand Down

0 comments on commit 2631026

Please # to comment.