Last active
September 8, 2015 16:46
-
-
Save derekwheee/10989841 to your computer and use it in GitHub Desktop.
Inline SVG with PNG fallback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img src="/path/to/image.svg" onerror="this.onerror=null; this.src='/path/to/image.png'"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the SVG doesn't load (doesn't exist, or browser doesn't support SVG), the
src
attribute gets replaced withimage.png
. If that doesn't load, theimg
is set tonull
to avoid an infinite loop, and will just show up as a broken image.