0

我正在使用 prettyphotos 来显示幻灯片和灯箱,但我如何才能获得灯箱中显示的当前照片 ID。

PrettyPhotos 提供回调函数 changepicturecallback: function()

我试过了,但无法获得当前的照片 ID。

我正在使用此代码

请帮助

$("a[rel^='prettyPhoto']").prettyPhoto({theme: 'light_square',slideshow:5000,
            changepicturecallback: function(){
            //Run on every image change
                $('.gallery-list li').index($('.selected')).find('img').attr('id');

            }
        });
4

3 回答 3

0

你可以试试

$('.pp_gallery').find('li').index($('.selected'));
于 2011-08-02T10:17:30.293 回答
0

这应该可以解决问题

$pp_pic_holder.find("#pp_full_res img").attr("id");

prettyphoto 不知何故没有获取运行时元素。

于 2012-03-19T17:26:16.013 回答
0

将图像的 id 传递给漂亮照片的一种方法是使用链接的标题属性。

如下所示:

<a href="foo/bar/preview.jpg" rel="prettyPhoto[pp_gal]" title="<div class='pictureId' style='display:none'>__HIDDEN_IMAGE_ID__</div>picture description">
<img src="thumbnail.jpg" alt="filename"/>
</a>

然后你可以像这样在 changepicturecallback 函数中获取图片 id:

$("a[href!='#'][rel^='prettyPhoto']").prettyPhoto({
   changepicturecallback: function () {
       var id = $(".pp_details .pp_description .pictureId").html();
       alert(id);

        }               
});
于 2012-12-19T09:38:10.520 回答