$(function() { $('img.artbox-lazy').lazyload({ skip_invisible: false }); lazyThreshold(); lazyEvent(); lazyEffect(); }); function lazyThreshold() { $.each($('img.artbox-lazy-threshold'), function(index, value) { var threshold = 200; var attribute = $(value).attr('data-threshold'); if(attribute) { threshold = attribute; } this.lazyload({ threshold: threshold }); }); } function lazyEvent() { $.each($('img.artbox-lazy-event'), function(index, value) { var event = 'click'; var attribute = $(value).attr('data-event'); if(attribute) { event = attribute; } this.lazyload({ event: event }); }); } function lazyEffect() { $.each($('img.artbox-lazy-effect'), function(index, value) { var effect = 'fadeIn'; var attribute = $(value).attr('data-effect'); if(attribute) { effect = attribute; } this.lazyload({ effect: effect }); }); }