Answers for "gallery template foreach one large image and five small"

PHP
0

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; ?>
Posted by: Guest on March-04-2021

Code answers related to "gallery template foreach one large image and five small"

Browse Popular Code Answers by Language