Merge pull request #9693 from JakubOnderka/image-helper-fix-vol2

fix: [internal] Normalize extension for image helper
pull/7010/merge
Jakub Onderka 2024-04-20 13:05:45 +02:00 committed by GitHub
commit 43c234f345
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -8,6 +8,7 @@ class ImageHelper extends AppHelper
private $imageCache = [];
/**
* Converts image file to data format
* @param string $imagePath Path to file
* @return string
* @throws Exception
@ -18,13 +19,13 @@ class ImageHelper extends AppHelper
return $this->imageCache[$imagePath];
}
$ext = pathinfo($imagePath, PATHINFO_EXTENSION);
$ext = strtolower(pathinfo($imagePath, PATHINFO_EXTENSION));
if ($ext === 'svg') {
$mime = 'image/svg+xml';
} else if ($ext === 'png') {
$mime = 'image/png';
} else {
throw new InvalidArgumentException("Only SVG and PNG images are supported");
throw new InvalidArgumentException("Only SVG and PNG images are supported, '$ext' file provided.");
}
try {