From 609a91a9b1bbee423a6bda2420dc4010b46757f6 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 19 Feb 2014 14:47:29 +0100 Subject: Show svg mime icons when no preview is available --- apps/files/js/files.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 1ec4c4ec7ab..dab060229e6 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -731,6 +731,9 @@ Files.getMimeIcon = function(mime, ready) { ready(Files.getMimeIcon.cache[mime]); } else { $.get( OC.filePath('files','ajax','mimeicon.php'), {mime: mime}, function(path) { + if(SVGSupport()){ + path = path.substr(0, path.length-4) + '.svg'; + } Files.getMimeIcon.cache[mime]=path; ready(Files.getMimeIcon.cache[mime]); }); @@ -785,8 +788,10 @@ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) { // this will make the browser cache the image var img = new Image(); img.onload = function(){ - //set preview thumbnail URL - ready(previewURL); + // if loading the preview image failed (no preview for the mimetype) then img.width will < 5 + if (img.width > 5) { + ready(previewURL); + } } img.src = previewURL; }); -- cgit v1.2.3 From 4715fb12c8001b8642c2e6dcef57ac216ef92c3d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 21 Feb 2014 14:06:15 +0100 Subject: Add url parameter to control whether previews should return 404 when the mimetype is unsupported --- apps/files/js/files.js | 1 + core/ajax/preview.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 8b252e69a1d..1f4bd6794f3 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -786,6 +786,7 @@ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) { } previewURL = previewURL.replace('(', '%28'); previewURL = previewURL.replace(')', '%29'); + previewURL += '&always=0'; // preload image to prevent delay // this will make the browser cache the image diff --git a/core/ajax/preview.php b/core/ajax/preview.php index 5c6d5ce25ab..285af3a8a76 100644 --- a/core/ajax/preview.php +++ b/core/ajax/preview.php @@ -11,6 +11,7 @@ $file = array_key_exists('file', $_GET) ? (string)$_GET['file'] : ''; $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; +$always = array_key_exists('always', $_GET) ? (bool)$_GET['always'] : true; if ($file === '') { //400 Bad Request @@ -28,7 +29,7 @@ if ($maxX === 0 || $maxY === 0) { try { $preview = new \OC\Preview(\OC_User::getUser(), 'files'); - if (!$preview->isMimeSupported(\OC\Files\Filesystem::getMimeType($file))) { + if (!$always and !$preview->isMimeSupported(\OC\Files\Filesystem::getMimeType($file))) { \OC_Response::setStatus(404); } else { $preview->setFile($file); -- cgit v1.2.3 From 7c4f81bd78b0933928056f6f59020837e1291525 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 24 Feb 2014 13:24:10 +0100 Subject: rename url parameter --- apps/files/js/files.js | 2 +- core/ajax/preview.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 1f4bd6794f3..f4546120702 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -786,7 +786,7 @@ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) { } previewURL = previewURL.replace('(', '%28'); previewURL = previewURL.replace(')', '%29'); - previewURL += '&always=0'; + previewURL += '&forceIcon=0'; // preload image to prevent delay // this will make the browser cache the image diff --git a/core/ajax/preview.php b/core/ajax/preview.php index 285af3a8a76..526719e8a1b 100644 --- a/core/ajax/preview.php +++ b/core/ajax/preview.php @@ -11,7 +11,7 @@ $file = array_key_exists('file', $_GET) ? (string)$_GET['file'] : ''; $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; -$always = array_key_exists('always', $_GET) ? (bool)$_GET['always'] : true; +$always = array_key_exists('forceIcon', $_GET) ? (bool)$_GET['forceIcon'] : true; if ($file === '') { //400 Bad Request -- cgit v1.2.3