useSrcset=true should also set src as fallback on img tag
See original GitHub issueIn browsers that do not support srcset
(e.g. IE11), ng-lazyload-image
fails silently - onLoad
is not even called with a false
argument.
The proper way to handle this would be, in my opinion, to also set the src
attribute to the largest image available in the srcset. This ensures that browsers without srcset
support will at least load an image.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Inputting a default image in case the src attribute of an html ...
Assuming that item has a property url that might be null, when it is then the image will show up as broken. That...
Read more >Fallback image if src doesn't exist for image tag – ReactJS
If the image can't be found it the callback is invoked. In the callback I set the src of the image tag to...
Read more ><img>: The Image Embed element - HTML - MDN Web Docs
The above example shows usage of the <img> element: The src attribute is required, and contains the path to the image you want...
Read more >How to Set the Equivalent of “src” Attribute of an <img> Tag in ...
In this snippet, you can find the solution of setting the equivalent of “src” attribute of an tag. For that, use the content...
Read more >How To Use In HTML »
There are three different kinds of URLs that can be used in the src attribute: ... and it's also reasonable to hotlink an...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It would work with
<picture>
, but wouldn’t with<img>
tags, since thesrcset
attribute has to be parsed to extract the correct image, e.g.:Parsing this should be pretty easy (at least for selecting the largest image), but I’m not sure how much of an overhead it would add. But doing so would enable at least somewhat working lazy loading for browsers that don’t support
srcset
attribute. Maybe it’s worth looking into srcset polyfills to see how they’re doing their detection and parsing.Hum… weird that
onLoad
is never called. It should be called withtrue
even ifsrcset
is not supported (since the image should be loaded anyway).ng-lazyload-image
does not know ifsrcset
is supported or not so it will assume it is (if useSrcset=true) and try to load it any way. It will then pass the path to the loaded image to the browser and then unsubscribes to all events.I do however agree that
ng-lazyload-image
should check ifsrcset
is supported but I’m not sure how. The only way I know is to useCSS.supports
but that is not supported in IE 🤦♂️.