summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-04-29 17:07:10 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-05-02 17:02:57 +0200
commit20893cc3b335049a144a53be24eaacb2e33a1480 (patch)
treec0795a4246bf6c38ec8b8ad9461e25b17ec9af74 /apps/files_sharing
parent49d9631eee1616b9ae2846886c3d428236c5b81a (diff)
downloadnextcloud-server-20893cc3b335049a144a53be24eaacb2e33a1480.tar.gz
nextcloud-server-20893cc3b335049a144a53be24eaacb2e33a1480.zip
Images on public sharing get downscaled to increase use experience - this will speed up loading time
- adding keep aspect to core/ajax/preview.php - remove duplicate method Preview::show() - no more hard coded mimetype of preview - remove .png from the preview urls - keep old route preview.png for backwards compatibility - aspect preserving previews are now cached
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/ajax/publicpreview.php8
-rw-r--r--apps/files_sharing/appinfo/routes.php8
-rw-r--r--apps/files_sharing/templates/public.php5
3 files changed, 15 insertions, 6 deletions
diff --git a/apps/files_sharing/ajax/publicpreview.php b/apps/files_sharing/ajax/publicpreview.php
index d12d212a2e6..d8c892f1b7f 100644
--- a/apps/files_sharing/ajax/publicpreview.php
+++ b/apps/files_sharing/ajax/publicpreview.php
@@ -16,6 +16,7 @@ $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36';
$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36';
$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
$token = array_key_exists('t', $_GET) ? (string) $_GET['t'] : '';
+$keepAspect = array_key_exists('a', $_GET) ? true : false;
if($token === ''){
\OC_Response::setStatus(400); //400 Bad Request
@@ -70,6 +71,10 @@ if(substr($path, 0, 1) === '/') {
$path = substr($path, 1);
}
+if ($keepAspect === true) {
+ $maxY = $maxX;
+}
+
if($maxX === 0 || $maxY === 0) {
\OC_Response::setStatus(400); //400 Bad Request
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
@@ -84,8 +89,9 @@ try{
$preview->setMaxX($maxX);
$preview->setMaxY($maxY);
$preview->setScalingUp($scalingUp);
+ $preview->setKeepAspect($keepAspect);
- $preview->show();
+ $preview->showPreview();
} catch (\Exception $e) {
\OC_Response::setStatus(500);
\OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG);
diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php
index 06e454b7d77..7c2834dc9c2 100644
--- a/apps/files_sharing/appinfo/routes.php
+++ b/apps/files_sharing/appinfo/routes.php
@@ -1,9 +1,9 @@
<?php
/** @var $this \OCP\Route\IRouter */
-$this->create('core_ajax_public_preview', '/publicpreview.png')->action(
-function() {
- require_once __DIR__ . '/../ajax/publicpreview.php';
-});
+$this->create('core_ajax_public_preview', '/publicpreview')->action(
+ function() {
+ require_once __DIR__ . '/../ajax/publicpreview.php';
+ });
// OCS API
diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index f3c75134a5f..7614e122e86 100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -30,7 +30,10 @@
<?php else: ?>
<?php if (substr($_['mimetype'], 0, strpos($_['mimetype'], '/')) == 'image'): ?>
<div id="imgframe">
- <img src="<?php p($_['downloadURL']); ?>" alt="" />
+ <img
+ src="<?php p(OCP\Util::linkToRoute( 'core_ajax_public_preview', array('x' => 1000, 'y' => 1000, 'a' => 'true', 'file' => $_['directory_path'], 't' => $_['dirToken']))); ?>"
+ class="publicpreview"
+ alt=""/>
</div>
<?php elseif (substr($_['mimetype'], 0, strpos($_['mimetype'], '/')) == 'video'): ?>
<div id="imgframe">