summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-07-30 17:22:20 +0200
committerMorris Jobke <hey@morrisjobke.de>2014-07-30 17:22:20 +0200
commit62b37fbb997c0244d37953b05e333cdb2279a31a (patch)
treef51b0d3613ed361a65770a27b4284ac235268e30
parentef3c0c508fc18fc0888097f920883cda7c5e1370 (diff)
parentc066320208da5211abe7e244bd2b045009367518 (diff)
downloadnextcloud-server-62b37fbb997c0244d37953b05e333cdb2279a31a.tar.gz
nextcloud-server-62b37fbb997c0244d37953b05e333cdb2279a31a.zip
Merge pull request #10024 from owncloud/preview-restrict-height
Also keep maxY into account when scaling a preview while preserving aspect ratio
-rw-r--r--apps/files_sharing/ajax/publicpreview.php4
-rw-r--r--core/ajax/preview.php4
-rwxr-xr-xlib/private/preview.php10
3 files changed, 8 insertions, 10 deletions
diff --git a/apps/files_sharing/ajax/publicpreview.php b/apps/files_sharing/ajax/publicpreview.php
index 0b2af7a6e59..f5343a7ef26 100644
--- a/apps/files_sharing/ajax/publicpreview.php
+++ b/apps/files_sharing/ajax/publicpreview.php
@@ -70,10 +70,6 @@ if(substr($path, 0, 1) === '/') {
$path = substr($path, 1);
}
-if ($keepAspect === true) {
- $maxY = $maxX;
-}
-
if($maxX === 0 || $maxY === 0) {
\OC_Response::setStatus(\OC_Response::STATUS_BAD_REQUEST);
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
diff --git a/core/ajax/preview.php b/core/ajax/preview.php
index d38043707ac..edbd41d2db4 100644
--- a/core/ajax/preview.php
+++ b/core/ajax/preview.php
@@ -21,10 +21,6 @@ if ($file === '') {
exit;
}
-if ($keepAspect === true) {
- $maxY = $maxX;
-}
-
if ($maxX === 0 || $maxY === 0) {
//400 Bad Request
\OC_Response::setStatus(400);
diff --git a/lib/private/preview.php b/lib/private/preview.php
index 8089379bde5..6172519c7d1 100755
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -561,9 +561,15 @@ class Preview {
$realX = (int)$image->width();
$realY = (int)$image->height();
- // compute $maxY using the aspect of the generated preview
+ // compute $maxY and $maxX using the aspect of the generated preview
if ($this->keepAspect) {
- $y = $x / ($realX / $realY);
+ $ratio = $realX / $realY;
+ if($x / $ratio < $y) {
+ // width restricted
+ $y = $x / $ratio;
+ } else {
+ $x = $y * $ratio;
+ }
}
if ($x === $realX && $y === $realY) {