Skip to content

Commit

Permalink
nette/utils 4
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 12, 2023
1 parent 7b09ee1 commit 032e96b
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/Http/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Nette\Http;

use Nette;
use Nette\Utils\Image;


/**
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}


Expand Down

0 comments on commit 032e96b

Please sign in to comment.