Browse Source

add config-option for an image's maximum filesize when generating previews

tags/v8.0.0beta2
Georg Ehrke 9 years ago
parent
commit
3af8bde949
2 changed files with 19 additions and 0 deletions
  1. 12
    0
      config/config.sample.php
  2. 7
    0
      lib/private/preview/image.php

+ 12
- 0
config/config.sample.php View File

@@ -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
*/

+ 7
- 0
lib/private/preview/image.php View File

@@ -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) {

Loading…
Cancel
Save