From befbf1c15031446130cb1d253aec5f82d0060dd8 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Wed, 1 Oct 2014 11:38:56 +0200 Subject: Load public preview via JS Backport of https://github.com/owncloud/core/pull/11368 to stable6 - since stable6 has no detection for SVG support this will just use the PNG icon instead of SVG ones. I believe this is a better solution than backporting the whole SVG support stuff and potentially breaking a lot. --- apps/files_sharing/css/public.css | 5 ----- apps/files_sharing/js/public.js | 23 +++++++++++++++++++++++ apps/files_sharing/templates/public.php | 20 ++++++++++---------- core/js/js.js | 17 +++++++++++++++++ 4 files changed, 50 insertions(+), 15 deletions(-) diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css index d3aea1a3a15..f51b7842ae9 100644 --- a/apps/files_sharing/css/public.css +++ b/apps/files_sharing/css/public.css @@ -71,11 +71,6 @@ p.info a { max-width:100%; } -/* some margin for the file type icon */ -#imgframe .publicpreview { - margin-top: 10%; -} - thead { padding-left: 0 !important; /* fixes multiselect bar offset on shared page */ } diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index 0696f8f8b5a..377be5ab866 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -11,6 +11,29 @@ $(document).ready(function() { if (typeof FileActions !== 'undefined') { var mimetype = $('#mimetype').val(); + var mimetypeIcon = $('#mimetypeIcon').val(); + var previewSupported = $('#previewSupported').val(); + + // dynamically load image previews + var params = { + x: $(document).width() * window.devicePixelRatio, + y: $(document).height() * window.devicePixelRatio, + a: 'true', + file: encodeURIComponent(this.initialDir + $('#filename').val()), + t: $('#sharingToken').val(), + scalingup: 0 + }; + + var img = $(''); + if (previewSupported === 'true' || mimetype.substr(0, mimetype.indexOf('/')) === 'image') { + img.attr('src', OC.filePath('files_sharing', 'ajax', 'publicpreview.php') + '?' + OC.buildQueryString(params)); + img.appendTo('#imgframe'); + } else if (mimetype.substr(0, mimetype.indexOf('/')) !== 'video') { + img.attr('src', mimetypeIcon); + img.attr('width', 32); + img.appendTo('#imgframe'); + } + // Show file preview if previewer is available, images are already handled by the template if (mimetype.substr(0, mimetype.indexOf('/')) != 'image' && $('.publicpreview').length === 0) { // Trigger default action if not download TODO diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index 23c63cfa217..96c06882a36 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -1,4 +1,8 @@ +
@@ -10,6 +14,9 @@ + + +