开发者

How I can get Current photo id in prettyphoto gallery

开发者 https://www.devze.com 2023-03-25 19:11 出处:网络
I am using prettyphotos to display slideshow and lightbox, but how I can get current photo id which is showing in Lightbox.

I am using prettyphotos to display slideshow and lightbox, but how I can get current photo id which is showing in Lightbox.

PrettyPhotos offer callback function changepicturecallback: function()

I tried it but am not able to get current photo id.

Am using this code

plz help

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

            }
        });


This should do the trick

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

prettyphoto is somehow not fetching runtime elements.


You could try

$('.pp_gallery').find('li').index($('.selected'));


One way to pass image's id to pretty photo is to use link's title attribute.

Like below:

<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>

And then you can get picture id in changepicturecallback function like this:

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

        }               
});
0

精彩评论

暂无评论...
验证码 换一张
取 消