Home Forums Add-ons Gallery Field Lightbox gallery with single image


Lightbox gallery with single image

  • I’m trying to get a page with multiple galleries to display the first image in each gallery and lightbox of the images from the gallery.

    I’ve successfully laid out the grid of images, some as ‘featured’, and successfully displaying the first image of each gallery in the post. But I just get a spinning wheel when I try and lightbox each gallery from said single image.

    Any help would be appreciated.

    	<?php if( have_rows( 'product' ) ) : ?>
                while( have_rows( 'product' ) ) : the_row();
                // Vars
                $images = get_sub_field( 'gallery' );
    			<?php if( get_sub_field('featured_image') ) { ?>
    				<li class="featured-product-frame">
    					<span class="featured-product-image">
    						 <a href="<?php echo $images['url']; ?>" rel="lightbox" >
    							<img src="<?php echo $images[0]["sizes"]["large"]; ?>" >
    			<?php } else { ?>
    				<li class="product-frame">
    					<span class="product-image">
    						<a href="<?php echo $images['url']; ?>" rel="lightbox" >
    							<img src="<?php echo $images[0]["sizes"]["large"]; ?>" >
    			<?php } ?>
            <?php endwhile; wp_reset_postdata(); ?>
    	<?php endif; ?>
  • Hi @adickey120

    This code wont work. What you’ve done is basically trying to fetch a single url from the array that contains all the image arrays.

    What javascript plugin are you using for the lightbox?

  • I would like to say I’m surprised by what you said… but I’m not…

    I’m using ‘Responsive Lightbox’ »

    I have also tried ‘Simple Lightbox’ »

  • Also, I’m pretty open to any plugin, paid or not, to accomplish this.

  • Haha okay 🙂

    Hmm.. the key info on that plugin is “Option to display single post images as a gallery”.

    Could you try that feature out with regular images just to see how the markup is done?

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Lightbox gallery with single image’ is closed to new replies.