shubhamjain / svg-loader

Plug 'n Play external SVG loader
MIT License
196 stars 20 forks source link

Implement optional fallback icon #7

Closed antoineKorbit closed 2 years ago

antoineKorbit commented 3 years ago

I added the possibility to have a fallback icon using the attribute data-fallback. The expected value is default SVG source code, that the library will use in case something went wrong during the download of the data-src attribute. I added more information and instructions how to use it in the README.md.

shubhamjain commented 3 years ago

What's the use case for this? IMO, this feels slightly cumbersome syntax, and it doesn't solve the issue that it's still reliant on svg-loader. Better way could be to have CSS background by default, which can be reset by svg-loader is SVG loading is successful.

antoineKorbit commented 3 years ago

I wasn't able to detect when the svg-loader failed to load the SVG from the URL. Interesting solution using CSS, but how loading successfully the SVG, can reset the CSS background ?