From 5d1a57cc42a55f45633227e437734af1643720c3 Mon Sep 17 00:00:00 2001 From: mcguffin Date: Wed, 21 Aug 2013 15:08:48 +0200 Subject: [PATCH 1/2] add option 'skip_duplicates' --- js/jquery.prettyPhoto.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/jquery.prettyPhoto.js b/js/jquery.prettyPhoto.js index 0436a49..ad64363 100644 --- a/js/jquery.prettyPhoto.js +++ b/js/jquery.prettyPhoto.js @@ -34,6 +34,7 @@ changepicturecallback: function(){}, /* Called everytime an item is shown/changed */ callback: function(){}, /* Called when prettyPhoto is closed */ ie6_fallback: true, + skip_duplicates:true, markup: '
\
 
\
\ @@ -759,6 +760,9 @@ if(isSet && settings.overlay_gallery) { currentGalleryPage = 0; toInject = ""; + if ( settings.skip_duplicates ) { + var image_sources = []; + } for (var i=0; i < pp_images.length; i++) { if(!pp_images[i].match(/\b(jpg|jpeg|png|gif)\b/gi)){ classname = 'default'; @@ -767,7 +771,12 @@ classname = ''; img_src = pp_images[i]; } - toInject += "
  • "; + if ( !settings.skip_duplicates || image_sources.indexOf(img_src) == -1 ) { + toInject += "
  • "; + if ( settings.skip_duplicates ) { + image_sources.push(img_src); + } + } }; toInject = settings.gallery_markup.replace(/{gallery}/g,toInject); From 0184d6c20901c81919ea2330a83838d1e2c37891 Mon Sep 17 00:00:00 2001 From: mcguffin Date: Tue, 3 Sep 2013 09:41:35 +0200 Subject: [PATCH 2/2] fix image counter. --- js/jquery.prettyPhoto.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/jquery.prettyPhoto.js b/js/jquery.prettyPhoto.js index ad64363..494e4a1 100644 --- a/js/jquery.prettyPhoto.js +++ b/js/jquery.prettyPhoto.js @@ -189,6 +189,10 @@ _build_overlay(event.target); // Build the overlay {this} being the caller } + // make array unique + if ( settings.skip_duplicates ) + pp_images = $.grep(pp_images, function(v, k) { return $.inArray(v ,pp_images) === k; }); + if(settings.hideflash) $('object,embed,iframe[src*=youtube],iframe[src*=vimeo]').css('visibility','hidden'); // Hide the flash _checkPosition($(pp_images).size()); // Hide the next/previous links if on first or last images.