luis-almeida / unveil

A very lightweight jQuery plugin to lazy load images
4.16k stars 676 forks source link

Added srcset support #147

Open milansimek opened 6 years ago

milansimek commented 6 years ago

As discussed in issue #35

pau1phi11ips commented 5 years ago

This makes more sense if added this way

var source = this.getAttribute(attrib);
source = source || this.getAttribute("data-src");
if (source) {
    if (this.tagName === 'IMG') {
        this.setAttribute("src", source);
    } else if (this.tagName === 'SOURCE') { // add srcset support
        this.setAttribute("srcset", source);
    } else {
        this.style.backgroundImage = 'url(' + source + ')';
    }
    if (typeof callback === "function") {
        callback.call(this);
    }
}
milansimek commented 5 years ago

No it doesn't. My pull request is for srcset attributes, not for source tags inside a picture tag.