summaryrefslogtreecommitdiffstats
path: root/lib/private/Preview/Generator.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Preview/Generator.php')
-rw-r--r--lib/private/Preview/Generator.php7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index fd75e51b638..5a264c2bbd5 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -84,6 +84,7 @@ class Generator {
* @param string $mimeType
* @return ISimpleFile
* @throws NotFoundException
+ * @throws \InvalidArgumentException if the preview would be invalid (in case the original image is invalid)
*/
public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL, $mimeType = null) {
$this->eventDispatcher->dispatch(
@@ -299,10 +300,15 @@ class Generator {
* @param int $maxHeight
* @return ISimpleFile
* @throws NotFoundException
+ * @throws \InvalidArgumentException if the preview would be invalid (in case the original image is invalid)
*/
private function generatePreview(ISimpleFolder $previewFolder, ISimpleFile $maxPreview, $width, $height, $crop, $maxWidth, $maxHeight) {
$preview = $this->helper->getImage($maxPreview);
+ if (!$preview->valid()) {
+ throw new \InvalidArgumentException('Failed to generate preview, failed to load image');
+ }
+
if ($crop) {
if ($height !== $preview->height() && $width !== $preview->width()) {
//Resize
@@ -325,6 +331,7 @@ class Generator {
$preview->resize(max($width, $height));
}
+
$path = $this->generatePath($width, $height, $crop);
try {
$file = $previewFolder->newFile($path);