Merge pull request #1222 from fyutins/2.x

Fix and add SVG support
This commit is contained in:
KodeStar 2023-11-11 14:58:41 +00:00 committed by GitHub
commit 768e7a6576
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -123,14 +123,16 @@ function isImage(string $file, string $extension): bool
return false;
}
$tempFileName = tempnam("/tmp", "image-check-");
$tempFileName = @tempnam("/tmp", "image-check-");
$handle = fopen($tempFileName, "w");
fwrite($handle, $file);
$size = @getimagesize($tempFileName);
fclose($handle);
if ($extension == 'svg') {
return 'image/svg+xml' === mime_content_type($tempFileName);
}
$size = @getimagesize($tempFileName);
return is_array($size) && str_starts_with($size['mime'], 'image');
}