-
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
Wrong image src when browser doesn't support srcset (eg. IE11) #496
Comments
I agree. Lets say we have the following code: @Component({
selector: 'image',
template: ` <img [lazyLoad]="images" [useSrcset]="true" /> `,
})
class ImageComponent {
images = `https://images.unsplash.com/photo-1434725039720-aaad6dd32dfe?fm=jpg 700w,
https://images.unsplash.com/photo-1437818628339-19ded67ade8e?fm=jpg 1100w`;
} What is expected result in IE here? Is it possible for you to use |
In my opinion the |
Sure but setting a According to the documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/srcset if (useSrcset && !('srcset' in element)) {
// Take the first image path in 'srcset'
const src = imagePath.split(',')[0].split(' ')[0];
element.src = src;
} |
Yes, this would definitely make sense. I would even do the same if |
Sorry for my late response. |
Not sure where your last comment with the proposed |
In the library there are several checks if the
srcset
attribute is supported in the current browser. If the browser doesn't support it it sets the givenimagePath
to thesrc
attribute which is my opinion shouldn't be done if theuseSrcset
flag is set totrue
. If this is the case we can assume that theimagePath
is asrcset
-string (eg.https://images.unsplash.com/photo-1434725039720-aaad6dd32dfe?fm=jpg 700w, https://images.unsplash.com/photo-1437818628339-19ded67ade8e?fm=jpg 1100w
) and not a single image url which is not a valid value for thesrc
attribute and breaks the loading behavior of the image in older browsers.This is probably related to the following issue: #334. Of course this behavior could be overwritten by using the available hooks. But to do this it there is a lot code which needs to be re-implemented manually which is pretty dangerous if you would like to keep the library updatable.
Versions:
The text was updated successfully, but these errors were encountered: