From 58f5e2accb1d92e16882fa63d649f7fbeb6cc9b6 Mon Sep 17 00:00:00 2001 From: Ian Date: Mon, 4 Nov 2013 12:39:12 -0500 Subject: [PATCH 1/2] Safety checks for data-src attribute so we don't attempt to load "undefined" image --- src/jail.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/jail.js b/src/jail.js index ad3a70c..2e8fd19 100644 --- a/src/jail.js +++ b/src/jail.js @@ -129,8 +129,10 @@ currentStack = $.extend( {}, images ); - // Load the image - _loadImage( options, $img ); + if ($img.attr('data-src')) { + // Load the image + _loadImage( options, $img ); + } // Image has been loaded so there is no need to listen anymore $(e.currentTarget).unbind( e.type + '.' + options.id ); @@ -283,6 +285,10 @@ container = (/scroll/i.test(options.event)) ? images.data("triggerElem") : $window, isVisible = true; + if (!$img.attr('data-src')) { + return false; + } + // If don't you want to load hidden images (default beahviour) if ( !options.loadHiddenImages ) { isVisible = _isVisibleInContainer( $img, container, options ) && $img.is(":visible"); From 2012db043bc511c1afd66edd219853ee3404bfdc Mon Sep 17 00:00:00 2001 From: Ian Date: Mon, 4 Nov 2013 12:39:12 -0500 Subject: [PATCH 2/2] Safety checks for data-src attribute so we don't attempt to load "undefined" image --- src/jail.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/jail.js b/src/jail.js index 8e2d2cf..854419b 100644 --- a/src/jail.js +++ b/src/jail.js @@ -129,8 +129,10 @@ currentStack = $.extend( {}, images ); - // Load the image - _loadImage( options, $img ); + if ($img.attr('data-src')) { + // Load the image + _loadImage( options, $img ); + } // Image has been loaded so there is no need to listen anymore $(e.currentTarget).unbind( e.type + '.' + options.id ); @@ -283,6 +285,10 @@ container = (/scroll/i.test(options.event)) ? images.data("triggerElem") : $window, isVisible = true; + if (!$img.attr('data-src')) { + return false; + } + // If don't you want to load hidden images (default beahviour) if ( !options.loadHiddenImages ) { isVisible = _isVisibleInContainer( $img, container, options ) && $img.is(":visible");