2012-09-04 36 views
0

我在這裏有這個wordpress電子商務網站/ products-page/rings/product-1-2 /和我正在使用一個名爲jquery-colorbox的插件,正如您從頁面鏈接I有4個圖像,2個是相同的,你點擊任何圖像時,它說圖庫有3個圖像(這是真的),但其中1個是重複的。有沒有從jquery-colorbox中刪除重複項?我試圖谷歌,並沒有發現什麼:(Wordpress jquery colorbox刪除重複項

如果任何人都可以把我在正確的方向,我將不勝感激。

這裏是我的代碼,如果它可以幫助

<div class="imagecol"> 
<a class="preview_link cboxElement" style="text-decoration:none;" href="/wp-content/uploads/2012/07/DSC_0118.jpg" rel="Teardrop Druzy Amethyst Ring"> 
<img id="product_image_736" class="product_image colorbox-736" width="400" src="/wp-content/uploads/2012/07/DSC_0118.jpg" title="Teardrop Druzy Amethyst Ring" alt="Teardrop Druzy Amethyst Ring"> 
<br> 
<div style="text-align:center; color:#F39B91;">Click To Enlarge</div> 
</a> 
<div class="wpcart_gallery" style="text-align:center; padding-top:5px;"> 
<a class="thickbox cboxElement" title="DSC_0118" href="/wp-content/uploads/2012/07/DSC_0118.jpg" rel="Teardrop Druzy Amethyst Ring" rev="/wp-content/uploads/2012/07/DSC_0118.jpg"> 
<img class="attachment-gold-thumbnails colorbox-736" width="50" height="50" title="DSC_0118" alt="DSC_0118" src="/wp-content/uploads/2012/07/DSC_0118-50x50.jpg"> 
</a> 
<a class="thickbox cboxElement" title="P7230376" href="/wp-content/uploads/2012/07/P7230376.jpg" rel="Teardrop Druzy Amethyst Ring" rev="/wp-content/uploads/2012/07/P7230376.jpg"> 
<img class="attachment-gold-thumbnails colorbox-736" width="50" height="50" title="P7230376" alt="P7230376" src="/wp-content/uploads/2012/07/P7230376-50x50.jpg"> 
</a> 
<a class="thickbox cboxElement" title="P7230378" href="/wp-content/uploads/2012/07/P7230378.jpg" rel="Teardrop Druzy Amethyst Ring" rev="/wp-content/uploads/2012/07/P7230378.jpg"> 
<img class="attachment-gold-thumbnails colorbox-736" width="50" height="50" title="P7230378" alt="P7230378" src="/wp-content/uploads/2012/07/P7230378-50x50.jpg"> 
</a> 
</div> 
</div> 

我說這個我<head></head>部分

<script type="text/javascript"> 

    $(document).ready(function(){ 
     var srcs = [], 
      temp; 
     $(".attachment-gold-thumbnails img").filter(function(){ 
      temp = $(this).attr("src"); 
      if($.inArray(temp, srcs) < 0){ 
       srcs.push(temp); 
       return false; 
      } 
      return true; 
     }).remove(); 
    }); 

    </script> 

,它仍然沒有工作:(

回答

1

代碼複製,但在這裏它是沒有少:

$(function(){ 
    var srcs = [], 
     temp; 
    $(".attachment-gold-thumbnails img").filter(function(){ 
     temp = $(this).attr("src"); 
     if($.inArray(temp, srcs) < 0){ 
      srcs.push(temp); 
      return false; 
     } 
     return true; 
    }).remove(); 
}); 

檢查source的詳細信息:

+0

我申請你的代碼.. 。我把它放在wpcart_gallery div類下面,它沒有工作:(我把它放在錯誤的地方? – user1269625

+0

申請。 –

+0

我更新了我的代碼,告訴你我做了什麼,但它仍然不起作用:( – user1269625

0

您可以使用此jQuery代碼達到這樣的:

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'); 
});