From 1f5fad4ebd110afa21d56844a6b96975b6334d46 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 19 Feb 2022 17:57:08 +1300 Subject: [PATCH] ENH Allow developers to decide if resampling is needed --- code/Controller/AssetAdmin.php | 2 +- code/Helper/ImageThumbnailHelper.php | 4 ++++ code/Model/ThumbnailGenerator.php | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/code/Controller/AssetAdmin.php b/code/Controller/AssetAdmin.php index 25c4c4746..71719e3c6 100644 --- a/code/Controller/AssetAdmin.php +++ b/code/Controller/AssetAdmin.php @@ -1207,7 +1207,7 @@ public function getMinimalistObjectFromData(File $file, $thumbnailLinks = true) public function generateThumbnails(File $file, $thumbnailLinks = false) { $links = []; - if (!$file->getIsImage()) { + if (!$file->getIsImage() || $file->config()->resample_images === false) { return $links; } $generator = $this->getThumbnailGenerator(); diff --git a/code/Helper/ImageThumbnailHelper.php b/code/Helper/ImageThumbnailHelper.php index 8e2f8b886..b4071699c 100644 --- a/code/Helper/ImageThumbnailHelper.php +++ b/code/Helper/ImageThumbnailHelper.php @@ -140,6 +140,10 @@ protected function generateThumbnails(File $file) { $generated = []; + if ($file->config()->resample_images === false) { + return $generated; + } + $store = Injector::inst()->get(AssetStore::class); $assetAdmin = AssetAdmin::singleton(); $generator = $assetAdmin->getThumbnailGenerator(); diff --git a/code/Model/ThumbnailGenerator.php b/code/Model/ThumbnailGenerator.php index 069439181..76213d906 100644 --- a/code/Model/ThumbnailGenerator.php +++ b/code/Model/ThumbnailGenerator.php @@ -98,7 +98,7 @@ public function generateThumbnailLink(AssetContainer $file, $width, $height, $gr */ public function generateThumbnail(AssetContainer $file, $width, $height) { - if (!$file->getIsImage() || !$file->exists()) { + if (!$file->exists() || !$file->getIsImage() || $file->config()->resample_images === false) { return null; } @@ -111,7 +111,7 @@ public function generateThumbnail(AssetContainer $file, $width, $height) $method = $this->config()->get('method'); return $file->$method($width, $height); } - + /** * Generate "src" property for this thumbnail. * This can be either a url or base64 encoded data