diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-01-21 17:09:46 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-01-21 17:09:46 +0100 |
commit | 8ba42abbe45affe7cd149c8e693c69b5994b2c98 (patch) | |
tree | baa6de9f810ae2048380cfa59a9a0fb023568189 | |
parent | 3deb6600d055b98f3363ca62b7b7656d107c7795 (diff) | |
parent | 374ddbff55719ee42986383e6700e01370d68627 (diff) | |
download | nextcloud-server-8ba42abbe45affe7cd149c8e693c69b5994b2c98.tar.gz nextcloud-server-8ba42abbe45affe7cd149c8e693c69b5994b2c98.zip |
Merge pull request #13432 from owncloud/animate_gifs_public_sharing
show animated gifs on public sharing page
-rw-r--r-- | apps/files_sharing/js/public.js | 12 | ||||
-rw-r--r-- | apps/files_sharing/lib/controllers/sharecontroller.php | 5 | ||||
-rw-r--r-- | apps/files_sharing/templates/public.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/tests/controller/sharecontroller.php | 4 | ||||
-rw-r--r-- | config/config.sample.php | 10 |
5 files changed, 30 insertions, 3 deletions
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index cbd135028f1..bec43a4fb57 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -97,7 +97,17 @@ OCA.Sharing.PublicApp = { }; var img = $('<img class="publicpreview" alt="">'); - if (previewSupported === 'true' || mimetype.substr(0, mimetype.indexOf('/')) === 'image' && mimetype !== 'image/svg+xml') { + + var fileSize = parseInt($('#filesize').val(), 10); + var maxGifSize = parseInt($('#maxSizeAnimateGif').val(), 10); + + if (mimetype === 'image/gif' && + (maxGifSize === -1 || fileSize <= (maxGifSize * 1024 * 1024))) { + img.attr('src', $('#downloadURL').val()); + img.appendTo('#imgframe'); + } else if (previewSupported === 'true' || + mimetype.substr(0, mimetype.indexOf('/')) === 'image' && + mimetype !== 'image/svg+xml') { img.attr('src', OC.filePath('files_sharing', 'ajax', 'publicpreview.php') + '?' + OC.buildQueryString(params)); img.appendTo('#imgframe'); } else if (mimetype.substr(0, mimetype.indexOf('/')) !== 'video') { diff --git a/apps/files_sharing/lib/controllers/sharecontroller.php b/apps/files_sharing/lib/controllers/sharecontroller.php index 69de717611c..1d8eabc1984 100644 --- a/apps/files_sharing/lib/controllers/sharecontroller.php +++ b/apps/files_sharing/lib/controllers/sharecontroller.php @@ -176,7 +176,9 @@ class ShareController extends Controller { $shareTmpl['server2serversharing'] = Helper::isOutgoingServer2serverShareEnabled(); $shareTmpl['protected'] = isset($linkItem['share_with']) ? 'true' : 'false'; $shareTmpl['dir'] = ''; - $shareTmpl['fileSize'] = \OCP\Util::humanFileSize(\OC\Files\Filesystem::filesize($originalSharePath)); + $nonHumanFileSize = \OC\Files\Filesystem::filesize($originalSharePath); + $shareTmpl['nonHumanFileSize'] = $nonHumanFileSize; + $shareTmpl['fileSize'] = \OCP\Util::humanFileSize($nonHumanFileSize); // Show file list if (Filesystem::is_dir($originalSharePath)) { @@ -202,6 +204,7 @@ class ShareController extends Controller { } $shareTmpl['downloadURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', array('token' => $token)); + $shareTmpl['maxSizeAnimateGif'] = $this->config->getSystemValue('max_filesize_animated_gifs_public_sharing', 10); return new TemplateResponse($this->appName, 'public', $shareTmpl, 'base'); } diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index 0384d9a60aa..4ec4d264b31 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -40,6 +40,8 @@ $previewSupported = OC\Preview::isMimeSupported($_['mimetype']) ? 'true' : 'fals <input type="hidden" name="mimetype" value="<?php p($_['mimetype']) ?>" id="mimetype"> <input type="hidden" name="previewSupported" value="<?php p($previewSupported); ?>" id="previewSupported"> <input type="hidden" name="mimetypeIcon" value="<?php p(OC_Helper::mimetypeIcon($_['mimetype'])); ?>" id="mimetypeIcon"> +<input type="hidden" name="filesize" value="<?php p($_['nonHumanFileSize']); ?>" id="filesize"> +<input type="hidden" name="maxSizeAnimateGif" value="<?php p($_['maxSizeAnimateGif']); ?>" id="maxSizeAnimateGif"> <header><div id="header" class="<?php p((isset($_['folder']) ? 'share-folder' : 'share-file')) ?>"> diff --git a/apps/files_sharing/tests/controller/sharecontroller.php b/apps/files_sharing/tests/controller/sharecontroller.php index f13e5b2e497..931cd506d43 100644 --- a/apps/files_sharing/tests/controller/sharecontroller.php +++ b/apps/files_sharing/tests/controller/sharecontroller.php @@ -155,7 +155,9 @@ class ShareControllerTest extends \PHPUnit_Framework_TestCase { 'protected' => 'true', 'dir' => '', 'downloadURL' => null, - 'fileSize' => '33 B' + 'fileSize' => '33 B', + 'nonHumanFileSize' => 33, + 'maxSizeAnimateGif' => 10, ); $expectedResponse = new TemplateResponse($this->container['AppName'], 'public', $sharedTmplParams, 'base'); $this->assertEquals($expectedResponse, $response); diff --git a/config/config.sample.php b/config/config.sample.php index 98da8aed356..ae22f3b1355 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -944,6 +944,16 @@ $CONFIG = array( 'forwarded_for_headers' => array('HTTP_X_FORWARDED', 'HTTP_FORWARDED_FOR'), /** + * max file size for animating gifs on public-sharing-site. + * If the gif is bigger, it'll show a static preview + * + * Value represents the maximum filesize in megabytes + * Default is 10 + * Set to -1 for no limit + */ +'max_filesize_animated_gifs_public_sharing' => 10, + +/** * This entry is just here to show a warning in case somebody copied the sample * configuration. DO NOT ADD THIS SWITCH TO YOUR CONFIGURATION! * |