From 862c4a854acd24801f034acfa32d8888ac0af422 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 14 Oct 2016 17:29:36 +0200 Subject: [PATCH] use mimetype icons in filepicker if there is no preview Signed-off-by: Robin Appelman --- core/js/oc-dialogs.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index b77063a9eae..7d12aa13b48 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -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)); -- 2.39.5