diff options
author | Brice Maron <brice@bmaron.net> | 2011-10-22 11:34:49 +0200 |
---|---|---|
committer | Brice Maron <brice@bmaron.net> | 2011-10-22 11:34:49 +0200 |
commit | 42306f1e35f901346feffed296397b2ed751fe74 (patch) | |
tree | c5b633a0478ba45877304d92e746583aa4458640 /apps | |
parent | 9d46c378b9cb7abe78958c087912e5533d1f2144 (diff) | |
download | nextcloud-server-42306f1e35f901346feffed296397b2ed751fe74.tar.gz nextcloud-server-42306f1e35f901346feffed296397b2ed751fe74.zip |
Avoid error when no image is provided for cover or thumbnail
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gallery/ajax/getCovers.php | 8 | ||||
-rw-r--r-- | apps/gallery/ajax/thumbnail.php | 14 |
2 files changed, 14 insertions, 8 deletions
diff --git a/apps/gallery/ajax/getCovers.php b/apps/gallery/ajax/getCovers.php index d84bf2a7903..b9c7558a53c 100644 --- a/apps/gallery/ajax/getCovers.php +++ b/apps/gallery/ajax/getCovers.php @@ -18,6 +18,7 @@ function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height, $tgtImg, $ default: exit(); } + if(!$myImage) exit(); $ratio_orig = $width_orig/$height_orig; if ($thumbnail_width/$thumbnail_height > $ratio_orig) { @@ -52,8 +53,11 @@ $targetImg = imagecreatetruecolor($numOfItems*$box_size, $box_size); $counter = 0; while (($i = $result->fetchRow()) && $counter < $numOfItems) { $imagePath = OC::$CONFIG_DATADIRECTORY . $i['file_path']; - CroppedThumbnail($imagePath, $box_size, $box_size, $targetImg, $counter*$box_size); - $counter++; + if(file_exists($imagePath)) + { + CroppedThumbnail($imagePath, $box_size, $box_size, $targetImg, $counter*$box_size); + $counter++; + } } header('Content-Type: image/png'); diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php index 325adb46bda..a1416452932 100644 --- a/apps/gallery/ajax/thumbnail.php +++ b/apps/gallery/ajax/thumbnail.php @@ -21,6 +21,7 @@ function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSr default: exit(); } + if(!$myImage) exit(); $ratio_orig = $width_orig/$height_orig; if ($thumbnail_width/$thumbnail_height > $ratio_orig) { @@ -50,9 +51,10 @@ $img = $_GET['img']; $tmp = OC::$CONFIG_DATADIRECTORY . $img; -header('Content-Type: image/png'); -$image = CroppedThumbnail($tmp, $box_size, $box_size); - -imagepng($image); -imagedestroy($image); -?> +if(file_exists($tmp)) +{ + header('Content-Type: image/png'); + $image = CroppedThumbnail($tmp, $box_size, $box_size); + imagepng($image); + imagedestroy($image); +}
\ No newline at end of file |