Skip to content
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

Allow automatic swapping in of img src from data-src when needed. #329

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

IDisposable
Copy link

To allow lazy-loading of any image, add an API method swapInDataSrc that will copy the value from img-tag attribute data-src into src. This allows using a tiny placeholder image in the src, while still allowing preloading of the next image for easy transitions. Note that this is convention-driven to expect markup like <img src="placeholder.jpg" data-src="realimage.png" />. Any later DOM manipulation will work just fine because we pull the data-src attribute (and delete it) once. We could add the ability to specify the swapping attributes and such, but meh.

To allow lazy-loading of any image, add an API method swapInDataSrc that will copy the value from img-tag attribute data-src into src. This allows using a tiny placeholder image in the src, while still allowing preloading of the next image for easy transitions.  Note that this is convention-driven to expect markup like <img src="placeholder.jpg" data-src="realimage.png" />.  Any later DOM manipulation will work _just fine_ because we pull the data-src attribute (and delete it) once.  We could add the ability to specify the swapping attributes and such, but meh.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant