diff --git a/src/Http/FileUpload.php b/src/Http/FileUpload.php index 65823e88..782e0d1d 100644 --- a/src/Http/FileUpload.php +++ b/src/Http/FileUpload.php @@ -10,6 +10,7 @@ namespace Nette\Http; use Nette; +use Nette\Utils\Image; /** @@ -206,14 +207,7 @@ function (string $message) use ($dest): void { */ public function isImage(): bool { - $flag = imagetypes(); - $types = array_filter([ - $flag & IMG_GIF ? 'image/gif' : null, - $flag & IMG_JPG ? 'image/jpeg' : null, - $flag & IMG_PNG ? 'image/png' : null, - $flag & IMG_WEBP ? 'image/webp' : null, - $flag & 256 ? 'image/avif' : null, // IMG_AVIF - ]); + $types = array_map(fn($type) => Image::typeToMimeType($type), Image::getSupportedTypes()); return in_array($this->getContentType(), $types, strict: true); } @@ -222,9 +216,9 @@ public function isImage(): bool * Loads an image. * @throws Nette\Utils\ImageException If the upload was not successful or is not a valid image */ - public function toImage(): Nette\Utils\Image + public function toImage(): Image { - return Nette\Utils\Image::fromFile($this->tmpName); + return Image::fromFile($this->tmpName); }