From 4cd13e76685f498c4f344bc786ecc8fe2cf91f7a Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Sun, 19 Mar 2017 20:23:23 +0100 Subject: [PATCH] Don't generate max preview twice If you request a preview of X by Y. And after calculating X and Y are equal to maxWidth and maxHeight then there is no reason to create a preview of that size. Signed-off-by: Roeland Jago Douma --- lib/private/Preview/Generator.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php index 32a732d858..9ccf6aaf4f 100644 --- a/lib/private/Preview/Generator.php +++ b/lib/private/Preview/Generator.php @@ -111,6 +111,11 @@ class Generator { // Calculate the preview size list($width, $height) = $this->calculateSize($width, $height, $crop, $mode, $maxWidth, $maxHeight); + // No need to generate a preview that is just the max preview + if ($width === $maxWidth && $height === $maxHeight) { + return $maxPreview; + } + // Try to get a cached preview. Else generate (and store) one try { $file = $this->getCachedPreview($previewFolder, $width, $height, $crop);