Skip to content

Commit fb07157

Browse files
committed
Bug Fix: xhr totalSize not always set
totalSize not always set so we should only throw errors if there was nothing to process.
1 parent 71106be commit fb07157

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

cacheImages.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cacheImages",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"title": "jQuery.cacheImages()",
55
"author": {
66
"name": "Fresh Vine",

jquery.cacheImages.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @author Paul Prins
88
* @link http://paulprins.net
9-
* @version 1.0
9+
* @version 1.2.0
1010
* @requires jQuery v1.7 or later
1111
*
1212
* Official jQuery plugin page:
@@ -92,12 +92,16 @@
9292
xhr.open('GET', src, true);
9393
xhr.responseType = 'arraybuffer'; // Cannot use the jQuery ajax method until it support this response type
9494
xhr.onload = function( e ){
95-
if (this.status == 200 && e.totalSize > 0 ){
95+
if (this.status == 200 ){
9696
localStorage[key] = 'data:image/' + imgType + ';base64,' + $.fn.cacheImages.base64EncodeResponse( this.response );
97+
}
98+
99+
if( localStorage[key] !== 'data:image/' + imgType + ';base64,'){
97100
$this.prop('src', localStorage[key] );
98101
if( $this.is('.cacheImagesRemove') ){
99102
$this.remove();
100103
}
104+
101105
self.cacheImagesConfig.done.call( $this, false );
102106
self.cacheImagesConfig.always.call( $this );
103107
}else{

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)