Support

Account

Home Forums Add-ons Flexible Content Field Using Flexible Content : Gallery with a Lightbox plugin

Solved

Using Flexible Content : Gallery with a Lightbox plugin

  • I have searched high and low and I’m yet to see a definitive answer to getting the Gallery feature within Flexible Content to show using any sort of Lightbox popup plugin.

    I am trying to create a Gallery that a customer can use, add their images and then scroll through them in the front end using a popup Lightbox effect.

    I have tried many codes shown online including those on the Gallery documentation page, with various plugins including Simple Lightbox as a number or users seem to have got this to work, but I have had no joy.

    All I get is the correct thumbnails showing on the page but when I click, I just get a new page with the full-size image.

    Does anyone have any solutions as I love the Flexible Content idea but it’s not worth having if I can’t utilise the code.

  • you need to add a js libary that provides the popup functionality.
    with plugins Simple Lightbox you can use:

    <?php $images = get_field('gallery');
    if( $images ): ?>
    <div class="gallery">
        <ul>
            <?php foreach( $images as $image ): 
                $content = '<li>';
                    $content .= '<a class="gallery_image" href="'. $image['url'] .'">';
                         $content .= '<img src="'. $image['sizes']['thumbnail'] .'" alt="'. $image['alt'] .'" />';
                    $content .= '</a>';
                $content .= '</li>';
                if ( function_exists('slb_activate') ){
        $content = slb_activate($content);
        }
        
    echo $content;?>
            <?php endforeach; ?>
        </ul>
    </div>
    <?php endif; ?>
  • Thanks this is exactly what I needed, I must have had a few incorrect coding in place before.

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

The topic ‘Using Flexible Content : Gallery with a Lightbox plugin’ is closed to new replies.