I'm displaying some images from Instagram in a PhotoSwipe gallery. The problem is that if the image gets deleted from Instagram, I get 404s in the gallery.
How can I check if the image results in 404 and if so, display a locally saved image (as a fallback)?
You can use the
onerror
attribute of<img>
tagif
image.png
does not exist, thendefault.png
is loaded