Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/gallery.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Paroz <github@oparoz.com>2015-09-18 02:24:23 +0300
committerOlivier Paroz <github@oparoz.com>2015-09-24 11:38:03 +0300
commit5fe47822bdf22c5e5622561b3588b0ba8893cd3f (patch)
tree1c3d10d056a2a5ac3840a2aa6874a0efa4391d9d
parente531e99f44c13c51e0c2fac7bedf7b86109ba620 (diff)
Retrieve the media type icon when loading an image fails
Problems are usually detected on the PHP side, when trying to generate a preview, but it's not the case for SVG and there could be other problems along the road, so we fetch the media type icon in case of failure Fixes #346
-rw-r--r--js/thumbnail.js27
1 files changed, 21 insertions, 6 deletions
diff --git a/js/thumbnail.js b/js/thumbnail.js
index 8b2e2329..70138e25 100644
--- a/js/thumbnail.js
+++ b/js/thumbnail.js
@@ -132,7 +132,7 @@ function Thumbnail (fileId, square) {
};
thumb.image.onerror = function () {
thumb.valid = false;
- thumb.loadingDeferred.resolve(null);
+ thumb.image.src = Thumbnails._getMimeIcon(preview.mimetype);
};
if (thumb.status === 200) {
@@ -140,18 +140,33 @@ function Thumbnail (fileId, square) {
'data:' + preview.mimetype + ';base64,' + preview.preview;
} else {
thumb.valid = false;
- var icon = OC.MimeType.getIconUrl(preview.mimetype);
- if (Gallery.ieVersion !== false) {
- icon = icon.substr(0, icon.lastIndexOf(".")) + ".png";
- }
- thumb.image.src = icon;
+ thumb.image.src = Thumbnails._getMimeIcon(preview.mimetype);
}
}
});
}
return batch;
+ },
+
+ /**
+ * Returns the link to the media type icon
+ *
+ * Modern browsers get an SVG, older ones a PNG
+ *
+ * @param mimeType
+ *
+ * @returns {*|string}
+ * @private
+ */
+ _getMimeIcon: function (mimeType) {
+ var icon = OC.MimeType.getIconUrl(mimeType);
+ if (Gallery.ieVersion !== false) {
+ icon = icon.substr(0, icon.lastIndexOf(".")) + ".png";
+ }
+ return icon;
}
+
};
window.Thumbnails = Thumbnails;