点击按钮打开prettyphoto(多个图像)

I am using prettyphoto, in that i can able to open single image as a prettyphoto on a button click. But I need the mutiple images to be open as prettyphoto on a button click.

here is the code i'm used. In this $image_src_cb1 is an array.

<?php $html .= $button_class_wrapper_open . "<a class='" . $button_class . $button_animation_class . $prettyphoto_class . "' data-rel='" . $pretty_photo_rel . "' href='" . $image_src_cb1 . "' ><span class='cover_boxes_button_text text_wrap'> " . $link_label1 .'</span>'. $button_icon . "<span class='a_overlay'></span></a>" . $button_class_wrapper_close;

can anyone give me suggestion to open multiple images on button click.

Using version: 3.1.5

Add an identifier to each image. For example the rel attribute:

<img src="image--1.jpg" rel="prettyPhoto[myGallery]" alt="">
<img src="image--2.jpg" rel="prettyPhoto[myGallery]" alt="">
<img src="image--3.jpg" rel="prettyPhoto[myGallery]" alt="">

<button type="button" class="foo">Gallery</button>

Pass the src attributes to prettyPhoto as an array:

$('.foo').on('click', function() {
    var ImgArr = [];

    $('[rel="prettyPhoto[myGallery]"]').each(function() {
        var src = $(this).attr('src');
        ImgArr.push(src);
    });
    $.prettyPhoto.open(ImgArr);
});