diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-01-22 23:02:38 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-01-22 23:02:38 +0100 |
commit | 5776bfec059f4fd32977e9ddbf97ca4d652dab7a (patch) | |
tree | a1aa3536f7dee9e28d9b0ccce244b8b7ff3f8e97 | |
parent | cb8440c55aee83f7a1359ad1a53e7255c06eb527 (diff) | |
parent | 3af8bde949ee14360574ec504be80a01ccd466ea (diff) | |
download | nextcloud-server-5776bfec059f4fd32977e9ddbf97ca4d652dab7a.tar.gz nextcloud-server-5776bfec059f4fd32977e9ddbf97ca4d652dab7a.zip |
Merge pull request #13449 from owncloud/image_preview_limit
add config-option for an image's maximum filesize when generating previews
-rw-r--r-- | config/config.sample.php | 12 | ||||
-rw-r--r-- | lib/private/preview/image.php | 7 |
2 files changed, 19 insertions, 0 deletions
diff --git a/config/config.sample.php b/config/config.sample.php index ae22f3b1355..2513a2658ad 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -621,6 +621,18 @@ $CONFIG = array( * original size. A value of ``1`` or ``null`` disables scaling. */ 'preview_max_scale_factor' => 10, + +/** + * max file size for generating image previews with imagegd (default behaviour) + * If the image is bigger, it'll try other preview generators, + * but will most likely show the default mimetype icon + * + * Value represents the maximum filesize in megabytes + * Default is 50 + * Set to -1 for no limit + */ +'preview_max_filesize_image' => 50, + /** * custom path for LibreOffice/OpenOffice binary */ diff --git a/lib/private/preview/image.php b/lib/private/preview/image.php index 986a44b48fd..e8473ebb8a4 100644 --- a/lib/private/preview/image.php +++ b/lib/private/preview/image.php @@ -26,6 +26,13 @@ class Image extends Provider { return false; } + $maxSizeForImages = \OC::$server->getConfig()->getSystemValue('preview_max_filesize_image', 50); + $size = $fileInfo->getSize(); + + if ($maxSizeForImages !== -1 && $size > ($maxSizeForImages * 1024 * 1024)) { + return false; + } + $image = new \OC_Image(); if($fileInfo['encrypted'] === true) { |