Added support to 404 URLs in thumbnail generator
This commit is contained in:
parent
dcfe6a00ea
commit
9e2f37477b
2 changed files with 20 additions and 5 deletions
|
@ -13,7 +13,14 @@ class TransferHelper
|
|||
}
|
||||
|
||||
set_time_limit(0);
|
||||
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');
|
||||
|
||||
|
|
|
@ -5,10 +5,18 @@ class SmartThumbnailGenerator implements IThumbnailGenerator
|
|||
{
|
||||
$tmpPath = tempnam(sys_get_temp_dir(), 'thumb') . '.jpg';
|
||||
|
||||
try
|
||||
{
|
||||
TransferHelper::download(
|
||||
$url,
|
||||
$tmpPath,
|
||||
null);
|
||||
}
|
||||
catch (SimpleException $e)
|
||||
{
|
||||
echo $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
$ret = self::generateFromFile($tmpPath, $dstPath, $width, $height);
|
||||
|
||||
|
|
Loading…
Reference in a new issue