From 20893cc3b335049a144a53be24eaacb2e33a1480 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Tue, 29 Apr 2014 17:07:10 +0200 Subject: 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 --- apps/files_sharing/ajax/publicpreview.php | 8 +++++++- apps/files_sharing/appinfo/routes.php | 8 ++++---- apps/files_sharing/templates/public.php | 5 ++++- 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'apps/files_sharing') 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 @@ 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 @@
- +
-- cgit v1.2.3