Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove duplicate images from jquery.colorbox.js

Hey ya'll I have a problem and I have no idea how to solve with the lack of jquery skills I have.

I am using jquery colorbox for a gallery with my images, problem there are some duplicate images and I am trying to remove it. I don't even know where to start looking...if someone could give me a tip on where to start I would greatly appericate it (ps - its my bday)

I think this is where I need to remove the duplicates, but like I said my jquery skills are awful

// Preloads images within a rel group
                if (settings.preloading) {
                    preload = [
                        getIndex(-1),
                        getIndex(1)
                    ];
                    while (i = $related[preload.pop()]) {
                        src = $.data(i, colorbox).href || i.href;
                        if ($.isFunction(src)) {
                            src = src.call(i);
                        }
                        if (isImage(src)) {
                            img = new Image();
                            img.src = src;
                        }

                    }
                }

Here is also the link to the file I am using...hope this helps

http://www.taranmarlowjewelry.com/wp-content/plugins/jquery-colorbox/js/jquery.colorbox.js?ver=1.3.19

like image 475
user1269625 Avatar asked Dec 13 '25 12:12

user1269625


2 Answers

After looking at your site, I had the same issue with colorbox...this will work

jQuery('document').ready(function($){
$(".wpcart_gallery a:first").removeClass("cboxElement");
jQuery(".wpcart_gallery img").click(function($){
jQuery(".wpcart_gallery a").addClass('cboxElement');
jQuery(this).closest('a').removeClass('cboxElement');
});
}); 
like image 159
user979331 Avatar answered Dec 15 '25 02:12

user979331


You can reach this using this jQuery code:

var arrayImgsColorbox = new Array();

$('.cboxElement').each(function(i, obj){
    if($.inArray($(obj).attr('href'), arrayImgsColorbox ) > -1)
        $(obj).removeClass('cboxElement');
    else
        arrayImgsColorbox[i] = $(obj).attr('href');
});
like image 36
Marcio Mazzucato Avatar answered Dec 15 '25 02:12

Marcio Mazzucato



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!