jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/images/basicimagefetcher.js
2016-03-04 22:39:49 -05:00

28 lines
591 B
JavaScript

define([], function () {
function loadImage(elem, url) {
if (elem.tagName !== "IMG") {
return new Promise(function (resolve, reject) {
var tmp = new Image();
tmp.onload = function () {
elem.style.backgroundImage = "url('" + url + "')";
resolve(elem);
};
tmp.src = url;
});
} else {
elem.setAttribute("src", url);
return Promise.resolve(elem);
}
}
return {
loadImage: loadImage
};
});