From b5edf09a696a43ec556a67fcf200cbb54a464457 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Thu, 7 Jul 2022 14:05:33 +0200 Subject: [PATCH] Don't try to generate double-density thumbs for small images --- models/Image.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/models/Image.php b/models/Image.php index 80a5cb46..99a9fbe6 100644 --- a/models/Image.php +++ b/models/Image.php @@ -74,7 +74,11 @@ class Image extends Asset { $thumbnail = new Thumbnail($this); $image_urls[1] = $this->getThumbnailUrl($width, $height, false); - $image_urls[2] = $this->getThumbnailUrl($width * 2, $height * 2, false); + + // Can we afford to generate double-density thumbnails as well? + if ((!isset($width) || $this->image_width >= $width * 2) && + (!isset($height) || $this->image_height >= $height * 2)) + $image_urls[2] = $this->getThumbnailUrl($width * 2, $height * 2, false); } else $image_urls[1] = $this->getUrl();