diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-05-19 13:13:41 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-05-19 17:25:32 +0200 |
commit | a5a4e0df1ca0028fae53d4618e334320d0be64fb (patch) | |
tree | 5c78e3e979e1661d4a8945de7a8768f83ea99358 /lib/private/Preview | |
parent | cdd1793efd353c3783f81adc8efa341271659cbc (diff) | |
download | nextcloud-server-a5a4e0df1ca0028fae53d4618e334320d0be64fb.tar.gz nextcloud-server-a5a4e0df1ca0028fae53d4618e334320d0be64fb.zip |
Fix crop condition
Make sure that when fetching the image from the cache we don't
accidentally fetch the cropped image just because it also start with
256-256
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib/private/Preview')
-rw-r--r-- | lib/private/Preview/Generator.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php index a19a19ef15f..2edea868ed0 100644 --- a/lib/private/Preview/Generator.php +++ b/lib/private/Preview/Generator.php @@ -144,7 +144,6 @@ class Generator { && ($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; $preview = $this->getSmallImagePreview($previewFolder, $file, $mimeType, $previewVersion, $crop); @@ -233,9 +232,17 @@ class Generator { foreach ($nodes as $node) { $name = $node->getName(); - if (($prefix === '' || strpos($name, $prefix) === 0) - && (str_starts_with($name, '256-256-crop') && $crop || str_starts_with($name, '256-256') && !$crop)) { - return $node; + if (($prefix === '' || str_starts_with($name, $prefix))) { + // Prefix match + if (str_starts_with($name, $prefix . '256-256-crop') && $crop) { + // Cropped image + return $node; + } + + if (str_starts_with($name, $prefix . '256-256.') && !$crop) { + // Uncropped image + return $node; + } } } |