gallery template foreach one large image and five small code example

Example: gallery template foreach one large image and five small

<?php 
$images = get_field('gallery');
$img_count=1;
if( $images ): ?>
    
        <?php foreach( $images as $image ):
if ($img_count == 1) { ?>
<div class="large">
                <a rel="gallery" href="<?php echo $image['url']; ?>">
                     <img src="<?php echo $image['sizes']['large']; ?>" alt="<?php echo $image['alt']; ?>" />
                </a>                
            </div>
<?php } else {?>
            <div class="thumb">
                <a rel="gallery" href="<?php echo $image['url']; ?>">
                     <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
                </a>                
            </div>
<?php } 
$img_count++; ?>
        <?php endforeach; ?>    
<?php endif; ?>

Tags:

Misc Example