]> source.dussan.org Git - nextcloud-server.git/commitdiff
use mimetype icons in filepicker if there is no preview
authorRobin Appelman <robin@icewind.nl>
Fri, 14 Oct 2016 15:29:36 +0000 (17:29 +0200)
committerRobin Appelman <robin@icewind.nl>
Fri, 14 Oct 2016 15:32:23 +0000 (17:32 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
core/js/oc-dialogs.js

index bdee8a1bb09be74070ffb9a7991fc42e74a28f83..edc0b3c797a351b2451ecfea2dc08a15e7f719a5 100644 (file)
@@ -769,10 +769,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));