mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 03:18:19 -07:00
29 lines
607 B
JavaScript
29 lines
607 B
JavaScript
define(['dom'], function (dom) {
|
|
'use strict';
|
|
|
|
function loadImage(elem, url) {
|
|
|
|
if (elem.tagName !== "IMG") {
|
|
|
|
elem.style.backgroundImage = "url('" + url + "')";
|
|
return Promise.resolve();
|
|
|
|
}
|
|
return loadImageIntoImg(elem, url);
|
|
}
|
|
|
|
function loadImageIntoImg(elem, url) {
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
dom.addEventListener(elem, 'load', resolve, {
|
|
once: true
|
|
});
|
|
elem.setAttribute("src", url);
|
|
});
|
|
}
|
|
|
|
return {
|
|
loadImage: loadImage
|
|
};
|
|
|
|
}); |