Skip to content

Instantly share code, notes, and snippets.

@A973C
Created June 3, 2021 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save A973C/2f331c4c20d5967da19ef8162f42f623 to your computer and use it in GitHub Desktop.
Save A973C/2f331c4c20d5967da19ef8162f42f623 to your computer and use it in GitHub Desktop.
How to handle loading of images that may not exist?
<img src="http://example.com/non-existent-image.jpg" onerror="this.onerror=null;this.src='http://example.com/existent-image.jpg';" />
<!-- Source: https://blog.imagekit.io/how-to-handle-loading-images-that-may-not-exist-on-your-website-92e6c3c6ea63 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment