2012-02-27 73 views
0

如何添加如何将LIGHTBOX添加到附件?

的rel = “收藏夹”

到下面的代码

<a href="<?php echo wp_get_attachment_url($post->ID); ?>" title="<?php echo wp_specialchars(get_the_title($post->ID), 1) ?>"><?php echo wp_get_attachment_image($post->ID, 'large'); ?></a> 

回答

0

你只需要在添加的rel = “收藏夹” 灯箱功能一个像这样的href:

<a rel="lightbox" href="<?php echo wp_get_attachment_url($post->ID); ?>" title="<?php echo wp_specialchars(get_the_title($post->ID), 1) ?>"><?php echo wp_get_attachment_image($post->ID, 'large'); ?></a> 

除此之外,我建议你可以通过你正在使用的灯箱的演示/教程/文档。它也需要包含适当的js和文件。你还需要使用简单的jquery代码来初始化它。像这样:

<script type="text/javascript"> 
$(function() { 
    // Use this example, or... 
    $('a[@rel*=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel 
    // This, or... 
    $('#gallery a').lightBox(); // Select all links in object with gallery ID 
    // This, or... 
    $('a.lightbox').lightBox(); // Select all links with lightbox class 
    // This, or... 
    $('a').lightBox(); // Select all links in the page 
    // ... The possibility are many. Use your creative or choose one in the examples above 
}); 
</script> 

您可以参考文档以了解灯箱脚本的确切示例。

+0

我做了所有这一切,但它仍然不起作用 – 2012-02-27 11:41:15

+0

会发生什么,你能分享你的网页网址吗? – Krunal 2012-05-04 11:25:21

相关问题