summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMorris Jobke <morris.jobke@gmail.com>2014-02-24 14:12:10 +0100
committerMorris Jobke <morris.jobke@gmail.com>2014-02-24 14:12:10 +0100
commit5fb1374b0f24dd034d7a07885ab7cecb420895a1 (patch)
tree7808941c034b92bf6ae7c20662e17e9c9d447988 /apps
parent8d17f6d6757b3aa9f8019c022a3ff1f777c5b535 (diff)
parent7c4f81bd78b0933928056f6f59020837e1291525 (diff)
downloadnextcloud-server-5fb1374b0f24dd034d7a07885ab7cecb420895a1.tar.gz
nextcloud-server-5fb1374b0f24dd034d7a07885ab7cecb420895a1.zip
Merge pull request #7285 from owncloud/mimeicons-svg
Show svg mime icons when no preview is available
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/filelist.js10
-rw-r--r--apps/files/js/files.js10
-rw-r--r--apps/files/lib/helper.php18
-rw-r--r--apps/files/tests/ajax_rename.php8
-rw-r--r--apps/files_sharing/public.php3
5 files changed, 31 insertions, 18 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 35fbdeecd39..550c10dba3e 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -145,7 +145,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',
@@ -173,7 +173,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,
@@ -969,7 +969,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();
@@ -1029,7 +1029,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);
@@ -1042,7 +1042,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 fbac601f67a..f4546120702 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -734,6 +734,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]);
});
@@ -783,13 +786,16 @@ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) {
}
previewURL = previewURL.replace('(', '%28');
previewURL = previewURL.replace(')', '%29');
+ previewURL += '&forceIcon=0';
// preload image to prevent delay
// 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..b9e41a352bc 100644
--- a/apps/files/lib/helper.php
+++ b/apps/files/lib/helper.php
@@ -22,6 +22,7 @@ class Helper
public static function determineIcon($file) {
if($file['type'] === 'dir') {
$dir = $file['directory'];
+ $icon = \OC_Helper::mimetypeIcon('dir');
$absPath = \OC\Files\Filesystem::getView()->getAbsolutePath($dir.'/'.$file['name']);
$mount = \OC\Files\Filesystem::getMountManager()->find($absPath);
if (!is_null($mount)) {
@@ -29,21 +30,22 @@ class Helper
if (!is_null($sid)) {
$sid = explode(':', $sid);
if ($sid[0] === 'shared') {
- return \OC_Helper::mimetypeIcon('dir-shared');
+ $icon = \OC_Helper::mimetypeIcon('dir-shared');
}
if ($sid[0] !== 'local' and $sid[0] !== 'home') {
- return \OC_Helper::mimetypeIcon('dir-external');
+ $icon = \OC_Helper::mimetypeIcon('dir-external');
}
}
}
- return \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/apps/files/tests/ajax_rename.php b/apps/files/tests/ajax_rename.php
index a1a5c8983ba..e53c0fb3dd1 100644
--- a/apps/files/tests/ajax_rename.php
+++ b/apps/files/tests/ajax_rename.php
@@ -110,7 +110,9 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
$this->assertEquals('/test', $result['data']['directory']);
$this->assertEquals(18, $result['data']['size']);
$this->assertEquals('httpd/unix-directory', $result['data']['mime']);
- $this->assertEquals(\OC_Helper::mimetypeIcon('dir'), $result['data']['icon']);
+ $icon = \OC_Helper::mimetypeIcon('dir');
+ $icon = substr($icon, 0, -3) . 'svg';
+ $this->assertEquals($icon, $result['data']['icon']);
$this->assertFalse($result['data']['isPreviewAvailable']);
}
@@ -165,7 +167,9 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
$this->assertEquals(18, $result['data']['size']);
$this->assertEquals('httpd/unix-directory', $result['data']['mime']);
$this->assertEquals('abcdef', $result['data']['etag']);
- $this->assertEquals(\OC_Helper::mimetypeIcon('dir'), $result['data']['icon']);
+ $icon = \OC_Helper::mimetypeIcon('dir');
+ $icon = substr($icon, 0, -3) . 'svg';
+ $this->assertEquals($icon, $result['data']['icon']);
$this->assertFalse($result['data']['isPreviewAvailable']);
}
diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php
index e7a5f5024b8..fe61dd4d5a0 100644
--- a/apps/files_sharing/public.php
+++ b/apps/files_sharing/public.php
@@ -32,7 +32,8 @@ function determineIcon($file, $sharingRoot, $sharingToken) {
if($file['isPreviewAvailable']) {
return OCP\publicPreview_icon($relativePath, $sharingToken) . '&c=' . $file['etag'];
}
- return OCP\mimetype_icon($file['mimetype']);
+ $icon = OCP\mimetype_icon($file['mimetype']);
+ return substr($icon, 0, -3) . 'svg';
}
if (isset($_GET['t'])) {