【问题标题】:Open image link as lightbox within prettyphoto inline overlay在 prettyphoto 内联叠加层中将图像链接作为灯箱打开
【发布时间】:2013-07-19 05:29:31
【问题描述】:

我有一个文本和一个图像作为 Prettyphoto 内嵌叠加层打开。但是,当单击其中的图像链接时,它会打开新的标签图像链接。

有没有办法让它在顶部打开另一个漂亮的照片叠加层? 那么当图像关闭时,另一个内联覆盖仍然打开?

【问题讨论】:

    标签: prettyphoto


    【解决方案1】:

    我想出的方法是让一个不同的灯箱插件自动将 rel=lightbox 添加到所有 img 文件类型。这使它覆盖了 prettyPhoto(我将其编码为使用 class="prettyPhoto-link" 而不是 rel

    在function.php中

      add_filter('the_content', 'chosted_image_attribute');
    
    function chosted_image_attribute($content) {
           global $post;
           $pattern ="/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i";
           $replacement = '<a$1href=$2$3.$4$5 rel="lightbox">';
           $content = preg_replace($pattern, $replacement, $content);
           return $content;
    }
    

    这是在 jquery.prettyPhoto.js 的顶部

    jQuery(function($){
        $(document).ready(function(){
            $(".prettyphoto-link").prettyPhoto({
                animation_speed:'normal',
                allow_resize: true,
                keyboard_shortcuts: true,
                show_title: false,
                social_tools: false,
                autoplay_slideshow: false
            });
        });
    });
    

    这可以帮助您从 PHP 代码中调用漂亮的照片,因为有时 rel 不起作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多