2013-04-03 122 views
0

我在WP網站(不是WP插件,但jQuery庫)使用TN3畫廊。與JS或jQuery加載畫廊縮略圖異步

在圖庫中,當您需要它們時,大圖像會加載,這很好,因爲頁面加載不會阻止。但是縮略圖會全部加載(甚至是不可見的縮略圖),並且頁面會一直卡住,直到它們全部被加載。

$images = get_field('gallery_images'); 
if($images): ?> 
    <div id="" class="mygallery"> 
    <ol class=""> 
     <?php foreach($images as $image): ?> 

     <li> 
      <?php if($image[$captionKey]): ?> 
      <div class="tn3 description"><?php echo $image[$captionKey]; ?></div> 
      <?php endif; ?>       

      <a href="<?php echo $image['sizes']['large']; ?>"> 
      <?php echo wp_get_attachment_image($image['id'], 'gallery-thumb'); ?> 
      </a> 
     </li> 

     <?php endforeach; ?> 
    </ol> 
    </div> 
<?php endif; ?> 

Is there away我可以使縮略圖在後臺加載而不會阻止頁面的其餘部分?

+0

圖像總是由瀏覽器異步加載。 「卡住」究竟意味着什麼?你想執行JavaScript嗎? – jwueller

+0

@elusive嗨,你可以看看這裏http://heseg.com/gallery/פורים-2012-בהישג/?lang = he,在加載縮略圖之前,頁面的其餘部分未加載(圖庫導航)。 – shannoga

+0

所以你想影響瀏覽器加載圖像的順序? – jwueller

回答

0

作爲變體,你可以插入縮略圖1px圖像,並添加一些屬性與真正的縮略圖src。在jQuery事件中的頁面準備就緒後,用該屬性值替換所有縮略圖src。