Open severo opened 4 years ago
fetchImage = src => {
const img = new Image();
img.src = src;
return img
.decode()
.then(() => img)
.catch(encodingError => {
// Do something with the error.
throw new Error(`Image ${src} could not be loaded: ${encodingError}`);
});
}
We could use https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decode#Examples instead of https://github.com/LyonDataViz/occupapp/blob/07624ea038016dc67d56021811f17e7fb4227707/src/utils/img.ts#L5...