Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Generate small preview straight away if Imaginary is enabled
Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv committed Apr 6, 2022
commit 3d1f22f6d8720ff0ed574bc21d32ea2a45a42c29
9 changes: 7 additions & 2 deletions lib/private/Preview/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ public function generatePreviews(File $file, array $specifications, $mimeType =
$previewVersion = $file->getPreviewVersion() . '-';
}

// If imaginary is enabled, and we request a small thumbnail,
// let's not generate the max preview for performance reasons
if (count($specifications) === 1
&& (($specifications[0]['width'] === 250 && $specifications[0]['height'] === 250)
|| ($specifications[0]['width'] === 150 && $specifications[0]['height'] === 150))
&& ($specifications[0]['width'] <= 256 || $specifications[0]['height'] <= 256)
&& preg_match(Imaginary::supportedMimeTypes(), $mimeType)
&& $this->config->getSystemValueString('preview_imaginary_url', 'invalid') !== 'invalid') {
$crop = $specifications[0]['crop'] ?? false;
Expand Down Expand Up @@ -221,6 +222,10 @@ public function generatePreviews(File $file, array $specifications, $mimeType =
return $preview;
}

/**
* Generate a small image straight away without generating a max preview first
* Preview generated is 256x256
*/
private function getSmallImagePreview(ISimpleFolder $previewFolder, File $file, string $mimeType, string $prefix, bool $crop) {
$nodes = $previewFolder->getDirectoryListing();

Expand Down