lazyload
lazyload copied to clipboard
Fetch image original either from data-original, or content or contentUrl attr
As microformats keep gaining traction, having attributes that describe better the page, and its information, becomes more and more relevant.
Many "objects" (movie, product, person, etc) can have a photo, which can be tag as itemprop="image". Normally if the element is an IMG the parser would refer to the SRC to know the content of that property. Since with lazy loading we lack that, other attributes can be used: content or contentUrl.
To avoid duplication of one could assume that a missing data-original implies the usage of content, or contentUrl to fetch the original image.
Thoughts?
:+1:
That is a good idea +:100:
i agree, :+1:
Rebuilt the min assets to solve conflict.
Thanks. As mentioned in CONTRIBUTING should not include minified version in pull request. These are handled by the building process. No need to remove though. I can cherrypick around it if I decide to include this.
I like the idea of supporting microformats. For me the problem is the attribute names are hardcoded. Next year there will be a new microformat which uses different attribute name. More hardcoded logic needed. It would be better if the attribute name was configurable. This way user can use any arbitrary attribute name he or she chooses.
Since there already is data_attribute
parameter this cannot be changed without breaking bc. One option would be to add attribute
parameter which overrides data_attribute
if the first one exists. Basically just resolve in constructor what the attribute name will be and use simple $.attr()
in rest of the code.
$.attr()
is anyway used already because it is faster than $.data()
and does not cache the results.
Good point, I'll refactor once I get the opportunity and came for your appreciation. By that point I'll also remove the minified commit. Thanks for taking a look into this.
I've updated the PR, there for your consideration. Thanks!
Ping?
@tuupola can this be merged in?