From 306bf71c62c7ef0fe30c297da6aea54db0177ba4 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 30 Sep 2014 15:23:16 +0200 Subject: [PATCH] Use SVG previews for public sharing Fixes https://github.com/owncloud/core/pull/11367#issuecomment-57306037 and https://github.com/owncloud/core/issues/9218 --- apps/files_sharing/js/public.js | 31 ++++++++++++++++--------- apps/files_sharing/templates/public.php | 23 +++++++++--------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index 1a2394f300..b303625440 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -56,6 +56,11 @@ OCA.Sharing.PublicApp = { } var mimetype = $('#mimetype').val(); + var mimetypeIcon = $('#mimetypeIcon').val(); + mimetypeIcon = mimetypeIcon.substring(0, mimetypeIcon.length - 3); + mimetypeIcon = mimetypeIcon + 'svg'; + + var previewSupported = $('#previewSupported').val(); if (typeof FileActions !== 'undefined') { // Show file preview if previewer is available, images are already handled by the template @@ -68,21 +73,25 @@ OCA.Sharing.PublicApp = { } } + // dynamically load image previews - if (mimetype.substr(0, mimetype.indexOf('/')) === 'image') { + 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 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 = $(''); + 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', OC.Util.replaceSVGIcon(mimetypeIcon)); + img.attr('width', 128); + img.appendTo('#imgframe'); } if (this.fileList) { diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index a4b3289d4c..46bf90b1b4 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -1,5 +1,8 @@ - + @@ -15,6 +18,10 @@ + + + +