use mimetype icons in filepicker if there is no preview

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2016-10-14 17:29:36 +02:00 committed by Morris Jobke
parent 9cff86ebc8
commit 862c4a854a
No known key found for this signature in database
GPG Key ID: 9CE5ED29E7FCD38A
1 changed files with 9 additions and 2 deletions

View File

@ -762,10 +762,17 @@ var OCdialogs = {
});
if (entry.type === 'file') {
var urlSpec = {
file: dir + '/' + entry.name
file: dir + '/' + entry.name,
};
$li.find('img').attr('src', OC.MimeType.getIconUrl(entry.mimetype));
var img = new Image();
var previewUrl = OC.generateUrl('/core/preview.png?') + $.param(urlSpec);
$li.find('img').attr('src', previewUrl);
img.onload = function() {
if (img.width > 5) {
$li.find('img').attr('src', previewUrl);
}
};
img.src = previewUrl;
}
else {
$li.find('img').attr('src', OC.Util.replaceSVGIcon(entry.icon));