Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #1840
    Mat Keller

    I would like to have a “Launch Gallery” button which launches the lightbox as well as links to the same from the individual thumbnails shown.

    I have an array of images coming from a Custom Field repeater that contains the IDs of the images to display. I only want to show the first two as thumbnails and the rest hidden but shown when the “Launch Gallery” button is clicked.

    How would I do that with your plugin?


    It’s not supported by WordPress galleries or the plugin itself. But I think it would be possible to achieve that using custom code in a theme.

    Mat Keller

    This is the code i’ve got so far:

    <?php if(get_sub_field('image_gallery')): ?>
    <div class="gallery">
    <?php $imagenum = count(get_sub_field('image_gallery')); if ($imagenum >=2) {
    echo '<div class="gallery-button"><a href="#" rel="lightbox[gallery]">View larger images ></a></div>';
    } ?>
    <?php $imagecount = 0; if(get_sub_field('image_gallery')){ 
    while((has_sub_field('image_gallery')) and ($imagecount < 4)) {
    $attachment_id = get_sub_field('image_path');
    $size = "medium";
    $image = wp_get_attachment_image_src( $attachment_id, $size );
    $fullimage = wp_get_attachment_image_src( $attachment_id, 'large');
    echo '<a href="'.$fullimage[0].'" rel="lightbox[gallery]"><img src="' . $image[0] . '" alt="' . get_sub_field('image_title') . '" class="asset-image-multi" /></a>';
    } ?></div>
    <?php endif; ?>
    Mat Keller

    The problems i see are that the button link launches the gallery but assumes the link contains an image and therefore there’s a blank image as the first one.
    I would also need to pass the gallery the entire array of images coming from the “image_gallery” loop.


    You’re right – it will not work that way. You’d need all the images (image links) available on the viewed page and a trigger(button, text, image) linking to an image – an element of a gallery.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.