Merge pull request #13432 from owncloud/animate_gifs_public_sharing
show animated gifs on public sharing page
This commit is contained in:
commit
8ba42abbe4
|
@ -97,7 +97,17 @@ OCA.Sharing.PublicApp = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var img = $('<img class="publicpreview" alt="">');
|
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.attr('src', OC.filePath('files_sharing', 'ajax', 'publicpreview.php') + '?' + OC.buildQueryString(params));
|
||||||
img.appendTo('#imgframe');
|
img.appendTo('#imgframe');
|
||||||
} else if (mimetype.substr(0, mimetype.indexOf('/')) !== 'video') {
|
} else if (mimetype.substr(0, mimetype.indexOf('/')) !== 'video') {
|
||||||
|
|
|
@ -176,7 +176,9 @@ class ShareController extends Controller {
|
||||||
$shareTmpl['server2serversharing'] = Helper::isOutgoingServer2serverShareEnabled();
|
$shareTmpl['server2serversharing'] = Helper::isOutgoingServer2serverShareEnabled();
|
||||||
$shareTmpl['protected'] = isset($linkItem['share_with']) ? 'true' : 'false';
|
$shareTmpl['protected'] = isset($linkItem['share_with']) ? 'true' : 'false';
|
||||||
$shareTmpl['dir'] = '';
|
$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
|
// Show file list
|
||||||
if (Filesystem::is_dir($originalSharePath)) {
|
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['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');
|
return new TemplateResponse($this->appName, 'public', $shareTmpl, 'base');
|
||||||
}
|
}
|
||||||
|
|
|
@ -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="mimetype" value="<?php p($_['mimetype']) ?>" id="mimetype">
|
||||||
<input type="hidden" name="previewSupported" value="<?php p($previewSupported); ?>" id="previewSupported">
|
<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="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')) ?>">
|
<header><div id="header" class="<?php p((isset($_['folder']) ? 'share-folder' : 'share-file')) ?>">
|
||||||
|
|
|
@ -155,7 +155,9 @@ class ShareControllerTest extends \PHPUnit_Framework_TestCase {
|
||||||
'protected' => 'true',
|
'protected' => 'true',
|
||||||
'dir' => '',
|
'dir' => '',
|
||||||
'downloadURL' => null,
|
'downloadURL' => null,
|
||||||
'fileSize' => '33 B'
|
'fileSize' => '33 B',
|
||||||
|
'nonHumanFileSize' => 33,
|
||||||
|
'maxSizeAnimateGif' => 10,
|
||||||
);
|
);
|
||||||
$expectedResponse = new TemplateResponse($this->container['AppName'], 'public', $sharedTmplParams, 'base');
|
$expectedResponse = new TemplateResponse($this->container['AppName'], 'public', $sharedTmplParams, 'base');
|
||||||
$this->assertEquals($expectedResponse, $response);
|
$this->assertEquals($expectedResponse, $response);
|
||||||
|
|
|
@ -943,6 +943,16 @@ $CONFIG = array(
|
||||||
*/
|
*/
|
||||||
'forwarded_for_headers' => array('HTTP_X_FORWARDED', 'HTTP_FORWARDED_FOR'),
|
'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
|
* This entry is just here to show a warning in case somebody copied the sample
|
||||||
* configuration. DO NOT ADD THIS SWITCH TO YOUR CONFIGURATION!
|
* configuration. DO NOT ADD THIS SWITCH TO YOUR CONFIGURATION!
|
||||||
|
|
Loading…
Reference in New Issue