diff --git a/dist/css/justifiedGallery.css b/dist/css/justifiedGallery.css index 1b9932dd..20cc73ff 100644 --- a/dist/css/justifiedGallery.css +++ b/dist/css/justifiedGallery.css @@ -1,7 +1,7 @@ -/*! - * justifiedGallery - v3.8.1 - * http://miromannino.github.io/Justified-Gallery/ - * Copyright (c) 2020 Miro Mannino +/* + * Justified Gallery - v3.9.0-645d8e1 + * http://miromannino.com/projects/justified-gallery/ + * Copyright (c) 2019 Miro Mannino * Licensed under the MIT license. */ .justified-gallery { diff --git a/dist/css/justifiedGallery.min.css b/dist/css/justifiedGallery.min.css index 1b9932dd..20cc73ff 100644 --- a/dist/css/justifiedGallery.min.css +++ b/dist/css/justifiedGallery.min.css @@ -1,7 +1,7 @@ -/*! - * justifiedGallery - v3.8.1 - * http://miromannino.github.io/Justified-Gallery/ - * Copyright (c) 2020 Miro Mannino +/* + * Justified Gallery - v3.9.0-645d8e1 + * http://miromannino.com/projects/justified-gallery/ + * Copyright (c) 2019 Miro Mannino * Licensed under the MIT license. */ .justified-gallery { diff --git a/dist/js/jquery.justifiedGallery.js b/dist/js/jquery.justifiedGallery.js index 846f611d..250dc3f5 100644 --- a/dist/js/jquery.justifiedGallery.js +++ b/dist/js/jquery.justifiedGallery.js @@ -1,7 +1,7 @@ /*! - * justifiedGallery - v3.8.1 + * justifiedGallery - v3.9.0-645d8e1 * http://miromannino.github.io/Justified-Gallery/ - * Copyright (c) 2020 Miro Mannino + * Copyright (c) 2022 Miro Mannino * Licensed under the MIT license. */ (function (factory) { @@ -127,16 +127,20 @@ * @returns {String} the suffix to use */ JustifiedGallery.prototype.newSrc = function (imageSrc, imgWidth, imgHeight, image) { - var newImageSrc; - + var newImageSrc = null; + if (this.settings.thumbnailPath) { newImageSrc = this.settings.thumbnailPath(imageSrc, imgWidth, imgHeight, image); - } else { + } + + if (newImageSrc == null) { + var matchRes = imageSrc.match(this.settings.extension); var ext = (matchRes !== null) ? matchRes[0] : ''; newImageSrc = imageSrc.replace(this.settings.extension, ''); newImageSrc = this.removeSuffix(newImageSrc, this.getUsedSuffix(newImageSrc)); newImageSrc += this.getSuffix(imgWidth, imgHeight) + ext; + } return newImageSrc; @@ -217,11 +221,12 @@ var imageSrc = $image.data('jg.src'); if (imageSrc) { imageSrc = this.newSrc(imageSrc, imgWidth, imgHeight, $image[0]); - + + var self = this; $image.one('error', function () { - this.resetImgSrc($image); //revert to the original thumbnail + self.resetImgSrc($image); //revert to the original thumbnail }); - + var loadNewImage = function () { // if (imageSrc !== newImageSrc) { $image.attr('src', imageSrc); @@ -658,7 +663,7 @@ this.insertToGallery(a); return a; }; - + /** * Sort the array using settings.comparator as comparator * @@ -670,7 +675,7 @@ this.insertToGallery(a); return a; }; - + /** * Reset the filters removing the 'jg-filtered' class from all the entries * diff --git a/dist/js/jquery.justifiedGallery.min.js b/dist/js/jquery.justifiedGallery.min.js index 2d761f5b..2b50a4c7 100644 --- a/dist/js/jquery.justifiedGallery.min.js +++ b/dist/js/jquery.justifiedGallery.min.js @@ -1,8 +1,8 @@ /*! - * justifiedGallery - v3.8.1 + * justifiedGallery - v3.9.0-645d8e1 * http://miromannino.github.io/Justified-Gallery/ - * Copyright (c) 2020 Miro Mannino + * Copyright (c) 2022 Miro Mannino * Licensed under the MIT license. */ -!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=function(t,i){return void 0===i&&(i="undefined"!=typeof window?require("jquery"):require("jquery")(t)),e(i),i}:e(jQuery)}(function(l){var r=function(t,i){this.settings=i,this.checkSettings(),this.imgAnalyzerTimeout=null,this.entries=null,this.buildingRow={entriesBuff:[],width:0,height:0,aspectRatio:0},this.lastFetchedEntry=null,this.lastAnalyzedIndex=-1,this.yield={every:2,flushed:0},this.border=0<=i.border?i.border:i.margins,this.maxRowHeight=this.retrieveMaxRowHeight(),this.suffixRanges=this.retrieveSuffixRanges(),this.offY=this.border,this.rows=0,this.spinner={phase:0,timeSlot:150,$el:l('
'),intervalId:null},this.scrollBarOn=!1,this.checkWidthIntervalId=null,this.galleryWidth=t.width(),this.$gallery=t};r.prototype.getSuffix=function(t,i){var e,s;for(e=i .jg-caption");return 0===i.length?null:i},r.prototype.displayEntry=function(t,i,e,s,n,r){t.width(s),t.height(r),t.css("top",e),t.css("left",i);var o=this.imgFromEntry(t);if(null!==o){o.css("width",s),o.css("height",n),o.css("margin-left",-s/2),o.css("margin-top",-n/2);var a=o.data("jg.src");if(a){a=this.newSrc(a,s,n,o[0]),o.one("error",function(){this.resetImgSrc(o)});var h=function(){o.attr("src",a)};"skipped"===t.data("jg.loaded")&&a?this.onImageEvent(a,function(){this.showImg(t,h),t.data("jg.loaded",!0)}.bind(this)):this.showImg(t,h)}}else this.showImg(t);this.displayEntryCaption(t)},r.prototype.displayEntryCaption=function(t){var i=this.imgFromEntry(t);if(null!==i&&this.settings.captions){var e=this.captionFromEntry(t);if(null===e){var s=i.attr("alt");this.isValidCaption(s)||(s=t.attr("title")),this.isValidCaption(s)&&(e=l('
'+s+"
"),t.append(e),t.data("jg.createdCaption",!0))}null!==e&&(this.settings.cssAnimation||e.stop().fadeTo(0,this.settings.captionSettings.nonVisibleOpacity),this.addCaptionEventsHandlers(t))}else this.removeCaptionEventsHandlers(t)},r.prototype.isValidCaption=function(t){return void 0!==t&&0this.settings.justifyThreshold;if(i||t&&"hide"===this.settings.lastRow&&!d){for(e=0;e img, > a > img").fadeTo(0,0));return-1}for(t&&!d&&"justify"!==this.settings.lastRow&&"hide"!==this.settings.lastRow&&(a=!1,0this.settings.justifyThreshold)),e=0;ethis.settings.refreshSensitivity&&(this.galleryWidth=t,this.rewind(),this.rememberGalleryHeight(),this.startImgAnalyzer(!0))}},this),this.settings.refreshTime)},r.prototype.isSpinnerActive=function(){return null!==this.spinner.intervalId},r.prototype.getSpinnerHeight=function(){return this.spinner.$el.innerHeight()},r.prototype.stopLoadingSpinnerAnimation=function(){clearInterval(this.spinner.intervalId),this.spinner.intervalId=null,this.setGalleryTempHeight(this.$gallery.height()-this.getSpinnerHeight()),this.spinner.$el.detach()},r.prototype.startLoadingSpinnerAnimation=function(){var t=this.spinner,i=t.$el.find("span");clearInterval(t.intervalId),this.$gallery.append(t.$el),this.setGalleryTempHeight(this.offY+this.buildingRow.height+this.getSpinnerHeight()),t.intervalId=setInterval(function(){t.phase=this.yield.every))return void this.startImgAnalyzer(t)}else if("error"!==e.data("jg.loaded"))return}0 img, > a > img, > svg, > a > svg",triggerEvent:function(t){this.$gallery.trigger(t)}},l.fn.justifiedGallery=function(n){return this.each(function(t,i){var e=l(i);e.addClass("justified-gallery");var s=e.data("jg.controller");if(void 0===s){if(null!=n&&"object"!==l.type(n)){if("destroy"===n)return;throw"The argument must be an object"}s=new r(e,l.extend({},r.prototype.defaults,n)),e.data("jg.controller",s)}else if("norewind"===n);else{if("destroy"===n)return void s.destroy();s.updateSettings(n),s.rewind()}s.updateEntries("norewind"===n)&&s.init()})}}); \ No newline at end of file +!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=function(t,i){return void 0===i&&(i="undefined"!=typeof window?require("jquery"):require("jquery")(t)),e(i),i}:e(jQuery)}(function(l){var r=function(t,i){this.settings=i,this.checkSettings(),this.imgAnalyzerTimeout=null,this.entries=null,this.buildingRow={entriesBuff:[],width:0,height:0,aspectRatio:0},this.lastFetchedEntry=null,this.lastAnalyzedIndex=-1,this.yield={every:2,flushed:0},this.border=0<=i.border?i.border:i.margins,this.maxRowHeight=this.retrieveMaxRowHeight(),this.suffixRanges=this.retrieveSuffixRanges(),this.offY=this.border,this.rows=0,this.spinner={phase:0,timeSlot:150,$el:l('
'),intervalId:null},this.scrollBarOn=!1,this.checkWidthIntervalId=null,this.galleryWidth=t.width(),this.$gallery=t};r.prototype.getSuffix=function(t,i){var e,s;for(e=i .jg-caption");return 0===i.length?null:i},r.prototype.displayEntry=function(t,i,e,s,n,r){t.width(s),t.height(r),t.css("top",e),t.css("left",i);var o=this.imgFromEntry(t);if(null!==o){o.css("width",s),o.css("height",n),o.css("margin-left",-s/2),o.css("margin-top",-n/2);var a=o.data("jg.src");if(a){a=this.newSrc(a,s,n,o[0]);var h=this;o.one("error",function(){h.resetImgSrc(o)});var g=function(){o.attr("src",a)};"skipped"===t.data("jg.loaded")&&a?this.onImageEvent(a,function(){this.showImg(t,g),t.data("jg.loaded",!0)}.bind(this)):this.showImg(t,g)}}else this.showImg(t);this.displayEntryCaption(t)},r.prototype.displayEntryCaption=function(t){var i=this.imgFromEntry(t);if(null!==i&&this.settings.captions){var e=this.captionFromEntry(t);if(null===e){var s=i.attr("alt");this.isValidCaption(s)||(s=t.attr("title")),this.isValidCaption(s)&&(e=l('
'+s+"
"),t.append(e),t.data("jg.createdCaption",!0))}null!==e&&(this.settings.cssAnimation||e.stop().fadeTo(0,this.settings.captionSettings.nonVisibleOpacity),this.addCaptionEventsHandlers(t))}else this.removeCaptionEventsHandlers(t)},r.prototype.isValidCaption=function(t){return void 0!==t&&0this.settings.justifyThreshold;if(i||t&&"hide"===this.settings.lastRow&&!d){for(e=0;e img, > a > img").fadeTo(0,0));return-1}for(t&&!d&&"justify"!==this.settings.lastRow&&"hide"!==this.settings.lastRow&&(a=!1,0this.settings.justifyThreshold)),e=0;ethis.settings.refreshSensitivity&&(this.galleryWidth=t,this.rewind(),this.rememberGalleryHeight(),this.startImgAnalyzer(!0))}},this),this.settings.refreshTime)},r.prototype.isSpinnerActive=function(){return null!==this.spinner.intervalId},r.prototype.getSpinnerHeight=function(){return this.spinner.$el.innerHeight()},r.prototype.stopLoadingSpinnerAnimation=function(){clearInterval(this.spinner.intervalId),this.spinner.intervalId=null,this.setGalleryTempHeight(this.$gallery.height()-this.getSpinnerHeight()),this.spinner.$el.detach()},r.prototype.startLoadingSpinnerAnimation=function(){var t=this.spinner,i=t.$el.find("span");clearInterval(t.intervalId),this.$gallery.append(t.$el),this.setGalleryTempHeight(this.offY+this.buildingRow.height+this.getSpinnerHeight()),t.intervalId=setInterval(function(){t.phase=this.yield.every))return void this.startImgAnalyzer(t)}else if("error"!==e.data("jg.loaded"))return}0 img, > a > img, > svg, > a > svg",triggerEvent:function(t){this.$gallery.trigger(t)}},l.fn.justifiedGallery=function(n){return this.each(function(t,i){var e=l(i);e.addClass("justified-gallery");var s=e.data("jg.controller");if(void 0===s){if(null!=n&&"object"!==l.type(n)){if("destroy"===n)return;throw"The argument must be an object"}s=new r(e,l.extend({},r.prototype.defaults,n)),e.data("jg.controller",s)}else if("norewind"===n);else{if("destroy"===n)return void s.destroy();s.updateSettings(n),s.rewind()}s.updateEntries("norewind"===n)&&s.init()})}}); \ No newline at end of file diff --git a/dist/justifiedGallery.min.zip b/dist/justifiedGallery.min.zip index 4a3ac541..601b9631 100644 Binary files a/dist/justifiedGallery.min.zip and b/dist/justifiedGallery.min.zip differ diff --git a/dist/justifiedGallery.zip b/dist/justifiedGallery.zip index fb961877..0b6a483e 100644 Binary files a/dist/justifiedGallery.zip and b/dist/justifiedGallery.zip differ diff --git a/src/js/jquery.justifiedGallery.js b/src/js/jquery.justifiedGallery.js index cff4dfc0..48d6bb43 100644 --- a/src/js/jquery.justifiedGallery.js +++ b/src/js/jquery.justifiedGallery.js @@ -1,5 +1,5 @@ /** - * Justified Gallery - v3.8.1 + * Justified Gallery - v3.9.0-645d8e1 * http://miromannino.github.io/Justified-Gallery/ * * Copyright (c) 2019 Miro Mannino diff --git a/src/js/justifiedGallery.js b/src/js/justifiedGallery.js index 75d5fe0a..a1889fdb 100755 --- a/src/js/justifiedGallery.js +++ b/src/js/justifiedGallery.js @@ -1,5 +1,5 @@ /** - * Justified Gallery - v3.8.1 + * Justified Gallery - v3.9.0-645d8e1 * http://miromannino.github.io/Justified-Gallery/ * * Copyright (c) 2019 Miro Mannino @@ -101,16 +101,20 @@ JustifiedGallery.prototype.getUsedSuffix = function (str) { * @returns {String} the suffix to use */ JustifiedGallery.prototype.newSrc = function (imageSrc, imgWidth, imgHeight, image) { - var newImageSrc; + var newImageSrc = null; if (this.settings.thumbnailPath) { newImageSrc = this.settings.thumbnailPath(imageSrc, imgWidth, imgHeight, image); - } else { + } + + if (newImageSrc == null) { + var matchRes = imageSrc.match(this.settings.extension); var ext = (matchRes !== null) ? matchRes[0] : ''; newImageSrc = imageSrc.replace(this.settings.extension, ''); newImageSrc = this.removeSuffix(newImageSrc, this.getUsedSuffix(newImageSrc)); newImageSrc += this.getSuffix(imgWidth, imgHeight) + ext; + } return newImageSrc; @@ -192,8 +196,9 @@ JustifiedGallery.prototype.displayEntry = function ($entry, x, y, imgWidth, imgH if (imageSrc) { imageSrc = this.newSrc(imageSrc, imgWidth, imgHeight, $image[0]); + var self = this; $image.one('error', function () { - this.resetImgSrc($image); //revert to the original thumbnail + self.resetImgSrc($image); //revert to the original thumbnail }); var loadNewImage = function () { diff --git a/src/less/justifiedGallery.less b/src/less/justifiedGallery.less index 19f43391..18413295 100644 --- a/src/less/justifiedGallery.less +++ b/src/less/justifiedGallery.less @@ -1,5 +1,5 @@ /* - * Justified Gallery - 3.8.1 + * Justified Gallery - v3.9.0-645d8e1 * http://miromannino.com/projects/justified-gallery/ * Copyright (c) 2019 Miro Mannino * Licensed under the MIT license.