mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 11:03:36 -05:00
471bc70463
[web] de-ng templates module (server-pro) GitOrigin-RevId: 8d2ffd6a109d61b11d6d7c1acb781b429da3891c
16 lines
478 B
JavaScript
16 lines
478 B
JavaScript
function loadingFailed(imgEl) {
|
|
return imgEl.complete && imgEl.naturalWidth === 0
|
|
}
|
|
|
|
document.querySelectorAll('[data-ol-fallback-image]').forEach(imgEl => {
|
|
function showFallback() {
|
|
imgEl.src = imgEl.getAttribute('data-ol-fallback-image')
|
|
}
|
|
if (loadingFailed(imgEl)) {
|
|
// The image loading failed before the sprinkle ran.
|
|
showFallback()
|
|
} else {
|
|
// The image loading might fail in the future.
|
|
imgEl.addEventListener('error', showFallback)
|
|
}
|
|
})
|