-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useSrcset=true should also set src as fallback on img tag #334
Comments
Hum.. weird that I do however agree that |
I would assume that In any case, I would argue |
Html is backward compatible so we can always add new attributes and we can also add new propertys in dynamic objects in javascript. With that being said, IE is not like any other browser so you may be right but if it throws an error it should also set the error image (and css class): ng-lazyload-image/src/lazyload-image.ts Lines 127 to 131 in d63ac6a
and call So I'm not sure why
I agree and it should be quite easy to do, I guess we just need to change the following lines: ng-lazyload-image/src/lazyload-image.ts Lines 71 to 75 in d63ac6a
to: element.src = imagePath;
if (useSrcset) {
element.srcset = imagePath;
} Do you have any input @sapierens? |
It would work with <img srcset="img-320w.jpg 320w,
img-480w.jpg 480w,
img-800w.jpg 800w"
sizes="(max-width: 320px) 280px,
(max-width: 480px) 440px,
800px"> 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 |
From my understanding, only "width" (w) and "resolution" (x) are valid units so it should be fairly easy BUT am not a big fan of adding this kind of logic into this lib, especially if the browsers start to support more units. I beleve it is better to make it possible to pass a custom |
I agree, trying to parse responsive images shouldn't be the responsibility of this library. The problem presented here actually goes back to my initial PR #231 (see under I also agree that the ability to pass custom |
This should be solved now with hooks ( |
In browsers that do not support
srcset
(e.g. IE11),ng-lazyload-image
fails silently -onLoad
is not even called with afalse
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 withoutsrcset
support will at least load an image.The text was updated successfully, but these errors were encountered: