Skip to content
Snippets Groups Projects
Commit d7fa2a0f authored by Robin Appelman's avatar Robin Appelman
Browse files

mimetype icon improvements

parent 8da00e2d
No related branches found
No related tags found
No related merge requests found
File moved
File moved
<?php
// Init owncloud
require_once('../../lib/base.php');
print OC_Helper::mimetypeIcon($_GET['mime']);
?>
......@@ -101,10 +101,14 @@ FileList={
$('.file_upload_filename').removeClass('highlight');
},
loadingDone:function(name){
$('tr[data-file="'+name+'"]').data('loading',false);
var mime=$('tr[data-file="'+name+'"]').data('mime');
$('tr[data-file="'+name+'"] td.filename').attr('style','background-image:url('+getMimeIcon(mime)+')');
$('tr[data-file="'+name+'"] td.filename').draggable(dragOptions);
var tr=$('tr[data-file="'+name+'"]');
tr.data('loading',false);
var mime=tr.data('mime');
tr.attr('data-mime',mime);
getMimeIcon(mime,function(path){
tr.find('td.filename').attr('style','background-image:url('+path+')');
});
tr.find('td.filename').draggable(dragOptions);
},
isLoading:function(name){
return $('tr[data-file="'+name+'"]').data('loading');
......
......@@ -473,11 +473,14 @@ function relative_modified_date(timestamp) {
else { return diffyears+' '+t('files','years ago'); }
}
function getMimeIcon(mime){
mime=mime.substr(0,mime.indexOf('/'));
var knownMimes=['image','audio'];
if(knownMimes.indexOf(mime)==-1){
mime='file';
function getMimeIcon(mime, ready){
if(getMimeIcon.cache[mime]){
ready(getMimeIcon.cache[mime]);
}else{
$.get( OC.filePath('files','ajax','mimeicon.php')+'?mime='+mime, function(path){
getMimeIcon.cache[mime]=path;
ready(getMimeIcon.cache[mime]);
});
}
return OC.imagePath('core','filetypes/'+mime);
}
getMimeIcon.cache={};
......@@ -96,6 +96,12 @@ class OC_Helper {
* Returns the path to the image of this file type.
*/
public static function mimetypeIcon( $mimetype ){
$alias=array('application/xml'=>'code/xml');
// echo $mimetype;
if(isset($alias[$mimetype])){
$mimetype=$alias[$mimetype];
// echo $mimetype;
}
// Replace slash with a minus
$mimetype = str_replace( "/", "-", $mimetype );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment