Fix and add SVG support
This commit is contained in:
parent
d2184eef0a
commit
431eafb2b6
1 changed files with 6 additions and 4 deletions
|
@ -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');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue