From 3051f375871a4a67a8dc7130806cc29d9be9bf1c Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Tue, 20 May 2014 20:15:53 +0200 Subject: [PATCH] Added checks for unexisting thumbnail sources --- src/ThumbnailGenerators/FlashThumbnailGenerator.php | 3 +++ src/ThumbnailGenerators/ImageGdThumbnailGenerator.php | 3 +++ src/ThumbnailGenerators/ImageImagickThumbnailGenerator.php | 3 +++ src/ThumbnailGenerators/SmartThumbnailGenerator.php | 3 +++ src/ThumbnailGenerators/VideoThumbnailGenerator.php | 3 +++ 5 files changed, 15 insertions(+) diff --git a/src/ThumbnailGenerators/FlashThumbnailGenerator.php b/src/ThumbnailGenerators/FlashThumbnailGenerator.php index ec79640e..f112d12c 100644 --- a/src/ThumbnailGenerators/FlashThumbnailGenerator.php +++ b/src/ThumbnailGenerators/FlashThumbnailGenerator.php @@ -3,6 +3,9 @@ class FlashThumbnailGenerator implements IThumbnailGenerator { public function generateFromFile($srcPath, $dstPath, $width, $height) { + if (!file_exists($srcPath)) + return false; + $tmpPath = tempnam(sys_get_temp_dir(), 'thumb') . '.png'; $cmd = sprintf( diff --git a/src/ThumbnailGenerators/ImageGdThumbnailGenerator.php b/src/ThumbnailGenerators/ImageGdThumbnailGenerator.php index 66458a76..3b165189 100644 --- a/src/ThumbnailGenerators/ImageGdThumbnailGenerator.php +++ b/src/ThumbnailGenerators/ImageGdThumbnailGenerator.php @@ -3,6 +3,9 @@ class ImageGdThumbnailGenerator implements IThumbnailGenerator { public function generateFromFile($srcPath, $dstPath, $width, $height) { + if (!file_exists($srcPath)) + return false; + $mime = mime_content_type($srcPath); switch ($mime) diff --git a/src/ThumbnailGenerators/ImageImagickThumbnailGenerator.php b/src/ThumbnailGenerators/ImageImagickThumbnailGenerator.php index 550d813d..831f2e19 100644 --- a/src/ThumbnailGenerators/ImageImagickThumbnailGenerator.php +++ b/src/ThumbnailGenerators/ImageImagickThumbnailGenerator.php @@ -3,6 +3,9 @@ class ImageImagickThumbnailGenerator implements IThumbnailGenerator { public function generateFromFile($srcPath, $dstPath, $width, $height) { + if (!file_exists($srcPath)) + return false; + $image = new Imagick($srcPath); $image = $image->coalesceImages(); diff --git a/src/ThumbnailGenerators/SmartThumbnailGenerator.php b/src/ThumbnailGenerators/SmartThumbnailGenerator.php index 47d83b81..b014a28d 100644 --- a/src/ThumbnailGenerators/SmartThumbnailGenerator.php +++ b/src/ThumbnailGenerators/SmartThumbnailGenerator.php @@ -26,6 +26,9 @@ class SmartThumbnailGenerator implements IThumbnailGenerator public function generateFromFile($srcPath, $dstPath, $width, $height) { + if (!file_exists($srcPath)) + return false; + $mime = mime_content_type($srcPath); switch ($mime) diff --git a/src/ThumbnailGenerators/VideoThumbnailGenerator.php b/src/ThumbnailGenerators/VideoThumbnailGenerator.php index 389b2e21..caa56101 100644 --- a/src/ThumbnailGenerators/VideoThumbnailGenerator.php +++ b/src/ThumbnailGenerators/VideoThumbnailGenerator.php @@ -3,6 +3,9 @@ class VideoThumbnailGenerator implements IThumbnailGenerator { public function generateFromFile($srcPath, $dstPath, $width, $height) { + if (!file_exists($srcPath)) + return false; + $tmpPath = tempnam(sys_get_temp_dir(), 'thumb') . '.jpg'; $cmd = sprintf(