When your website means business.

ACF, Gallery | Type: PHPACF Repeater Gallery (Image Array)

This example shows a full page width, with 4 gallery images across. This approach requires the ‘Image Array’ return value on the image field.

It’s possible to grab the ‘alt’ from the image array, but I’ve found people rarely complete that field when they upload images: thus the ‘gallery_imagetitle’ field. The ‘rel=”lightbox” ‘ bit triggers the modal window for the lightbox plugin.

<div class="medium-12 columns gallery">
<?php 
if(get_field('event_images')):
    echo '<div class="row">';
    echo '<div class="image-container">';
    while(has_sub_fields('event_images')):
        $galimg = get_sub_field('gallery_image');
        $galimgtitle = get_sub_field('gallery_imagetitle');
        if ($galimg) {
        $url = $galimg['url'];
        $size = 'thumbnail';
        $thumb = $galimg['sizes'][ $size ];
        echo '<div class="medium-3 columns galimg">';
        echo '<a href="'.$url.'" title="'.$galimgtitle.'" rel="lightbox">';
        echo '<img src="'.$thumb.'" alt="'.$galimgtitle.'" />';
        echo '</a>';
        echo '</div>';
        }
    endwhile;
    echo '</div>';
    echo '</div>';
endif;
?>
</div>
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept