Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

img data-src attribute #13081

Closed
tsamu opened this issue Oct 13, 2015 · 3 comments
Closed

img data-src attribute #13081

tsamu opened this issue Oct 13, 2015 · 3 comments

Comments

@tsamu
Copy link

tsamu commented Oct 13, 2015

If you use data-src attribute angular loads the image depending the position of the attribute.
http://jsfiddle.net/ryo2vg88/3/

@tsamu tsamu changed the title img data-src bug img data-src attribute Oct 13, 2015
@pkozlowski-opensource
Copy link
Member

I'm not sure what you are trying to do, but if you want to provide a dynamic URL for an image you should use ngSrc directive: https://docs.angularjs.org/api/ng/directive/ngSrc

Having both src and data-src on one element doesn't make much sense.

@tsamu
Copy link
Author

tsamu commented Oct 13, 2015

Just try to use data-src attribute to lazy load images.
http://jsfiddle.net/ryo2vg88/5/

@dinbror
Copy link

dinbror commented Oct 17, 2015

+1

Hey @pkozlowski-opensource.
Can you please elaborate:

  • <img data-ng-src="{{imgsrc}}"> adds a src on the image tag (expected)
  • <img data-src="{{imgsrc}}"> doesn't do anything (expected).
  • <img data-src="{{imgsrc}}" src="base64 encode string"> replaces src with data-src attribute in chrome, safari (webkit), not in firefox (didn't expect it to do anything).
  • <img src="base64 encode string" data-src="{{imgsrc}}"> replaces src with data-src attribute in firefox, not in webkit browsers (didn't expect it to do anything).

So when you both have a data-src and src attribute on an image angular somehow tries to resolve it but it doesn't work consistently across browsers!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants