Added support to 404 URLs in thumbnail generator

This commit is contained in:
Marcin Kurczewski 2014-05-19 19:27:22 +02:00
parent dcfe6a00ea
commit 9e2f37477b
2 changed files with 20 additions and 5 deletions

View file

@ -13,7 +13,14 @@ class TransferHelper
}
set_time_limit(0);
$srcHandle = fopen($srcUrl, 'rb');
try
{
$srcHandle = fopen($srcUrl, 'rb');
}
catch (Exception $e)
{
throw new SimpleException('Cannot open URL for reading: ' . $e->getMessage());
}
if (!$srcHandle)
throw new SimpleException('Cannot open URL for reading');

View file

@ -5,10 +5,18 @@ class SmartThumbnailGenerator implements IThumbnailGenerator
{
$tmpPath = tempnam(sys_get_temp_dir(), 'thumb') . '.jpg';
TransferHelper::download(
$url,
$tmpPath,
null);
try
{
TransferHelper::download(
$url,
$tmpPath,
null);
}
catch (SimpleException $e)
{
echo $e->getMessage();
return false;
}
$ret = self::generateFromFile($tmpPath, $dstPath, $width, $height);