Skip to content

Commit f9a69df

Browse files
Pavel Wpaveljanda
authored andcommitted
Fix - catch exception from Nette\Utils\Image::fromFile() when the image is unknown (e.g empty file).
1 parent edac889 commit f9a69df

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/ImageStorage.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Nette\SmartObject;
1111
use Nette\Utils\Image as NetteImage;
1212
use Nette\Utils\Strings;
13+
use Nette\Utils\UnknownImageFileException;
1314

1415
class ImageStorage
1516
{
@@ -211,7 +212,11 @@ public function fromIdentifier($args): Image
211212
return new Image(false, '#', '#', 'Can not find image');
212213
}
213214

214-
$_image = NetteImage::fromFile($file);
215+
try {
216+
$_image = NetteImage::fromFile($file);
217+
} catch (UnknownImageFileException $e) {
218+
return new Image(false, '#', '#', 'Unknown type of file');
219+
}
215220

216221
if ($script->hasCrop() && !$isNoImage) {
217222
call_user_func_array([$_image, 'crop'], $script->crop);

0 commit comments

Comments
 (0)