Skip to content

Commit 93f192b

Browse files
committed
Bug Fix: Break out when url is already running
1 parent 8c79e69 commit 93f192b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

jquery.cacheImages.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,22 @@
6363
// Check if the image has already been cached, if it has lets bounce out of here
6464
this.data('cachedImageSrc', src);
6565
this.prop('src', localSrcEncoded);
66+
self.cacheImagesConfig.done.call( this, localSrcEncoded );
67+
self.cacheImagesConfig.always.call( this );
68+
return;
69+
}else if( localSrcEncoded === 'pending' ){
70+
// This is either not an image, or the URL is already being processed somewhere else
71+
self.cacheImagesConfig.fail.call( this );
72+
self.cacheImagesConfig.always.call( this );
73+
return; // stop running
6674
}else{
6775
// The image has not yet been cached, so we need to get on that.
6876
this.prop('src', ''); // This will cancel the request if it hasn't already been finished
6977
var imgType = src.match(/\.(jpg|jpeg|png|gif)$/i); // Break out the filename to get the type
7078
if( imgType && imgType.length){ // Get us the type of file
7179
imgType = imgType[1].toLowerCase() == 'jpg' ? 'jpeg' : imgType[1].toLowerCase();
7280
}
73-
if( typeof imgType === 'undefined' || localSrcEncoded === 'pending' ){
81+
if( typeof imgType === 'undefined' ){
7482
// This is either not an image, or the URL is already being processed somewhere else
7583
self.cacheImagesConfig.fail.call( this );
7684
self.cacheImagesConfig.always.call( this );

jquery.cacheImages.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)