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 <oparoz@users.noreply.github.com>2015-09-28 00:31:56 +0300
committerOlivier Paroz <oparoz@users.noreply.github.com>2015-09-28 00:31:56 +0300
commitc2b5905be6b4c0f6007cf8bc9ec7e0cdb0a8149b (patch)
tree8988d665167037e31abdf2fceb19ed7c009c19d9
parentc29d6785a9ad2d49629595025f7fe928266ad6a2 (diff)
parent5fe47822bdf22c5e5622561b3588b0ba8893cd3f (diff)
Merge pull request #354 from owncloud/Dont-die-when-trying-to-load-a-bad-image
Retrieve the media type icon when loading an image fails
-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;