aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/preview.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-09-29 17:10:08 +0200
committerRobin Appelman <icewind@owncloud.com>2015-09-29 17:10:08 +0200
commita5ad5bf29bdba3aae34473a7fd5114f2ae750be9 (patch)
treea6c1eb828e738828533b704404f149c193022dc3 /lib/private/preview.php
parentfbe296df17f4d97fde4b7148198cde11c29fb8b7 (diff)
downloadnextcloud-server-a5ad5bf29bdba3aae34473a7fd5114f2ae750be9.tar.gz
nextcloud-server-a5ad5bf29bdba3aae34473a7fd5114f2ae750be9.zip
Fix preview caching
Diffstat (limited to 'lib/private/preview.php')
-rw-r--r--lib/private/preview.php44
1 files changed, 19 insertions, 25 deletions
diff --git a/lib/private/preview.php b/lib/private/preview.php
index cd92f15b921..1127048b7fd 100644
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -838,19 +838,16 @@ class Preview {
$askedHeight = $this->getMaxY();
if ($this->mode === self::MODE_COVER) {
- list($scaleWidth, $scaleHeight) =
+ list($askedWidth, $askedHeight) =
$this->applyCover($askedWidth, $askedHeight, $previewWidth, $previewHeight);
- } else {
- $scaleWidth = $askedWidth;
- $scaleHeight = $askedHeight;
}
/**
* Phase 1: If required, adjust boundaries to keep aspect ratio
*/
if ($this->keepAspect) {
- list($scaleWidth, $scaleHeight) =
- $this->applyAspectRatio($scaleWidth, $scaleHeight, $previewWidth, $previewHeight);
+ list($askedWidth, $askedHeight) =
+ $this->applyAspectRatio($askedWidth, $askedHeight, $previewWidth, $previewHeight);
}
/**
@@ -858,7 +855,7 @@ class Preview {
* Takes the scaling ratio into consideration
*/
list($newPreviewWidth, $newPreviewHeight) = $this->scale(
- $image, $scaleWidth, $scaleHeight, $previewWidth, $previewHeight
+ $image, $askedWidth, $askedHeight, $previewWidth, $previewHeight
);
// The preview has been resized and should now have the asked dimensions
@@ -870,28 +867,25 @@ class Preview {
/**
* Phase 3: We're still not there yet, so we're clipping and filling
- * to match the asked dimensions if we're not asked to keep aspect ratio
+ * to match the asked dimensions
*/
+ // It turns out the scaled preview is now too big, so we crop the image
+ if ($newPreviewWidth >= $askedWidth && $newPreviewHeight >= $askedHeight) {
+ $this->crop($image, $askedWidth, $askedHeight, $newPreviewWidth, $newPreviewHeight);
+ $this->storePreview($fileId, $askedWidth, $askedHeight);
- if (!$this->keepAspect) {
- // It turns out the scaled preview is now too big, so we crop the image
- if ($newPreviewWidth >= $askedWidth && $newPreviewHeight >= $askedHeight) {
- $this->crop($image, $askedWidth, $askedHeight, $newPreviewWidth, $newPreviewHeight);
- $this->storePreview($fileId, $askedWidth, $askedHeight);
-
- return;
- }
+ return;
+ }
- // At least one dimension of the scaled preview is too small,
- // so we fill the space with a transparent background
- if (($newPreviewWidth < $askedWidth || $newPreviewHeight < $askedHeight)) {
- $this->cropAndFill(
- $image, $askedWidth, $askedHeight, $newPreviewWidth, $newPreviewHeight
- );
- $this->storePreview($fileId, $askedWidth, $askedHeight);
+ // At least one dimension of the scaled preview is too small,
+ // so we fill the space with a transparent background
+ if (($newPreviewWidth < $askedWidth || $newPreviewHeight < $askedHeight)) {
+ $this->cropAndFill(
+ $image, $askedWidth, $askedHeight, $newPreviewWidth, $newPreviewHeight
+ );
+ $this->storePreview($fileId, $askedWidth, $askedHeight);
- return;
- }
+ return;
}
// The preview is smaller, but we can't touch it