12 lines
283 B
JavaScript
12 lines
283 B
JavaScript
|
export function isImageValid(src) {
|
||
|
return new Promise(function (resolve) {
|
||
|
var img = document.createElement('img');
|
||
|
img.onerror = function () {
|
||
|
return resolve(false);
|
||
|
};
|
||
|
img.onload = function () {
|
||
|
return resolve(true);
|
||
|
};
|
||
|
img.src = src;
|
||
|
});
|
||
|
}
|