Skip to content

Commit

Permalink
Merge pull request #1222 from fyutins/2.x
Browse files Browse the repository at this point in the history
Fix and add SVG support
  • Loading branch information
KodeStar authored Nov 11, 2023
2 parents d2184ee + 431eafb commit 768e7a6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

0 comments on commit 768e7a6

Please sign in to comment.