Skip to content

Commit

Permalink
Merge pull request #1252 from leochenftw/1.10
Browse files Browse the repository at this point in the history
ENH Allow developers to decide if resampling is needed
  • Loading branch information
michalkleiner authored Apr 2, 2022
2 parents 689f798 + 1f5fad4 commit d3c58c7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion code/Controller/AssetAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions code/Helper/ImageThumbnailHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions code/Model/ThumbnailGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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
Expand Down

0 comments on commit d3c58c7

Please sign in to comment.