blacklisting shit images

This commit is contained in:
Martin Donnelly 2015-08-14 11:16:58 +01:00
parent ab44d3462a
commit 91bac301f9

View File

@ -8,24 +8,37 @@
* https://github.com/luis-almeida
*/
;(function($) {
;
(function($) {
var blackList = ['feeds.feedburner.com', 'pi.feedsportal.com', 'rc.feedsportal.com'];
$.fn.unveil = function(threshold, callback) {
var $w = $(window),
th = threshold || 0,
retina = window.devicePixelRatio > 1,
attrib = retina? "data-src-retina" : "data-src",
attrib = retina ? "data-src-retina" : "data-src",
images = this,
loaded;
this.one("unveil", function() {
var source = this.getAttribute(attrib);
source = source || this.getAttribute("data-src");
if (source) {
var flag = false;
for (var item in blacklist) {
if (source.indexOf(item)) {
flag = true;
}
}
if (source && !flag) {
this.setAttribute("src", source);
if (typeof callback === "function") callback.call(this);
}
if (flag) {
this.hide();
}
});
function unveil() {
@ -53,4 +66,4 @@
};
})(window.jQuery || window.Zepto);
})(window.jQuery || window.Zepto);