diff options
author | Olivier Paroz <github@oparoz.com> | 2015-06-06 16:21:36 +0200 |
---|---|---|
committer | Olivier Paroz <github@oparoz.com> | 2015-06-06 16:25:04 +0200 |
commit | 71d65cb713ebfb85ee19f9f3cd17dd915360fe9b (patch) | |
tree | 7281b8a32d148d27ae375dd1c45308416e63eee7 /lib/private/preview/image.php | |
parent | 16708ae1873ddd563c3177b87cf7a4c395dca609 (diff) | |
download | nextcloud-server-71d65cb713ebfb85ee19f9f3cd17dd915360fe9b.tar.gz nextcloud-server-71d65cb713ebfb85ee19f9f3cd17dd915360fe9b.zip |
Fix max preview, some resizing and caching issues and force preview providers to resize their previews properly
* introduces a method in OC_Image which doesn't stretch images when trying to make them fit in a box
* adds the method to all key providers so that they can do their job, as expected by the Preview class
* improves the caching mechanism of Preview in order to reduce I/O and to avoid filling the available disk space
* fixes some long standing issues
* **contains mostly tests**
Diffstat (limited to 'lib/private/preview/image.php')
-rw-r--r-- | lib/private/preview/image.php | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/private/preview/image.php b/lib/private/preview/image.php index 2c69d29f4cb..dbaf5deb08d 100644 --- a/lib/private/preview/image.php +++ b/lib/private/preview/image.php @@ -33,7 +33,7 @@ abstract class Image extends Provider { public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { //get fileinfo $fileInfo = $fileview->getFileInfo($path); - if(!$fileInfo) { + if (!$fileInfo) { return false; } @@ -46,15 +46,19 @@ abstract class Image extends Provider { $image = new \OC_Image(); - if($fileInfo['encrypted'] === true) { + if ($fileInfo['encrypted'] === true) { $fileName = $fileview->toTmpFile($path); } else { $fileName = $fileview->getLocalFile($path); } $image->loadFromFile($fileName); $image->fixOrientation(); + if ($image->valid()) { + $image->scaleDownToFit($maxX, $maxY); - return $image->valid() ? $image : false; + return $image; + } + return false; } } |