diff options
-rw-r--r-- | apps/files/js/filelist.js | 10 | ||||
-rw-r--r-- | apps/files/js/files.js | 9 | ||||
-rw-r--r-- | apps/files/lib/helper.php | 14 | ||||
-rw-r--r-- | core/ajax/preview.php | 30 |
4 files changed, 37 insertions, 26 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index a855d6cbe59..b2de0161aa8 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -129,7 +129,7 @@ window.FileList={ if (loading) { imgurl = OC.imagePath('core', 'loading.gif'); } else { - imgurl = OC.imagePath('core', 'filetypes/file.png'); + imgurl = OC.imagePath('core', 'filetypes/file'); } var tr = this.createRow( 'file', @@ -157,7 +157,7 @@ window.FileList={ var tr = this.createRow( 'dir', name, - OC.imagePath('core', 'filetypes/folder.png'), + OC.imagePath('core', 'filetypes/folder'), OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/'), size, lastModified, @@ -907,7 +907,7 @@ $(document).ready(function() { uploadtext.attr('currentUploads', currentUploads); var translatedText = n('files', 'Uploading %n file', 'Uploading %n files', currentUploads); if (currentUploads === 0) { - var img = OC.imagePath('core', 'filetypes/folder.png'); + var img = OC.imagePath('core', 'filetypes/folder'); data.context.find('td.filename').attr('style','background-image:url('+img+')'); uploadtext.text(translatedText); uploadtext.hide(); @@ -967,7 +967,7 @@ $(document).ready(function() { if (data.errorThrown === 'abort') { //cleanup uploading to a dir var uploadtext = $('tr .uploadtext'); - var img = OC.imagePath('core', 'filetypes/folder.png'); + var img = OC.imagePath('core', 'filetypes/folder'); uploadtext.parents('td.filename').attr('style','background-image:url('+img+')'); uploadtext.fadeOut(); uploadtext.attr('currentUploads', 0); @@ -980,7 +980,7 @@ $(document).ready(function() { if (data.errorThrown === 'abort') { //cleanup uploading to a dir var uploadtext = $('tr .uploadtext'); - var img = OC.imagePath('core', 'filetypes/folder.png'); + var img = OC.imagePath('core', 'filetypes/folder'); uploadtext.parents('td.filename').attr('style','background-image:url('+img+')'); uploadtext.fadeOut(); uploadtext.attr('currentUploads', 0); 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; }); diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php index ac8a2ad3200..fec1297b180 100644 --- a/apps/files/lib/helper.php +++ b/apps/files/lib/helper.php @@ -36,14 +36,16 @@ class Helper } } } - return \OC_Helper::mimetypeIcon('dir'); + $icon = \OC_Helper::mimetypeIcon('dir'); + }else{ + if($file['isPreviewAvailable']) { + $pathForPreview = $file['directory'] . '/' . $file['name']; + return \OC_Helper::previewIcon($pathForPreview) . '&c=' . $file['etag']; + } + $icon = \OC_Helper::mimetypeIcon($file['mimetype']); } - if($file['isPreviewAvailable']) { - $pathForPreview = $file['directory'] . '/' . $file['name']; - return \OC_Helper::previewIcon($pathForPreview) . '&c=' . $file['etag']; - } - return \OC_Helper::mimetypeIcon($file['mimetype']); + return substr($icon, 0, -3) . 'svg'; } /** diff --git a/core/ajax/preview.php b/core/ajax/preview.php index a1267d6f5cf..5c6d5ce25ab 100644 --- a/core/ajax/preview.php +++ b/core/ajax/preview.php @@ -7,34 +7,38 @@ */ \OC_Util::checkLoggedIn(); -$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; +$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; -if($file === '') { +if ($file === '') { //400 Bad Request \OC_Response::setStatus(400); \OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG); exit; } -if($maxX === 0 || $maxY === 0) { +if ($maxX === 0 || $maxY === 0) { //400 Bad Request \OC_Response::setStatus(400); \OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG); exit; } -try{ +try { $preview = new \OC\Preview(\OC_User::getUser(), 'files'); - $preview->setFile($file); - $preview->setMaxX($maxX); - $preview->setMaxY($maxY); - $preview->setScalingUp($scalingUp); + if (!$preview->isMimeSupported(\OC\Files\Filesystem::getMimeType($file))) { + \OC_Response::setStatus(404); + } else { + $preview->setFile($file); + $preview->setMaxX($maxX); + $preview->setMaxY($maxY); + $preview->setScalingUp($scalingUp); + } $preview->show(); -}catch(\Exception $e) { +} catch (\Exception $e) { \OC_Response::setStatus(500); \OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG); -}
\ No newline at end of file +} |