ressio / lazy-load-xt

Lazy load XT is a jQuery plugin for images, videos and other media
http://ress.io/lazy-load-xt-jquery/
MIT License
1.36k stars 245 forks source link

Doesn't use data-src in the srcset extension #4

Closed paylesworth closed 10 years ago

paylesworth commented 10 years ago

The srcset extension works great but it does not use the data-src attribute. The HTML5 srcset does not require the 1x image in the src to be listed again in the srcset. If I duplicate the URL from data-src in the data-srcset with a 1x after it, all is good but this is redundant.

Maybe after the "return false" if there is no srcset you could append the data-src URL with a 1x. Then it would find that one for 1x screens.

paylesworth commented 10 years ago

I just realized that I don't even need the data-src if I am using the srcset extension. Is that the idea?

aykevl commented 9 years ago

I did it this way, without the srcset extension:

$.lazyLoadXT.onshow = undefined;                                                                                                          
if ('srcset' in (new Image())) {
  $.lazyLoadXT.onshow = function () {
    var el = $(this);
    el.attr('srcset', el.attr('data-srcset'));
  };
}