Any idea how to fetch image dimension class to each image in a gallery (portrait or landscape)?
<div class="gallery rel">
<?php $images = get_field('gallery');
if( $images ): ?>
<ul class="list-unstyled slick m0 p0">
<?php foreach( $images as $image ): ?>
<?php
$width = $image['sizes'][ $size . '-width' ];
$height = $image['sizes'][ $size . '-height' ];
?>
<li>
<img src="<?php bloginfo( 'template_directory' ); ?>/default.svg" data-lazy="<?php echo $image['sizes']['large']; ?>" alt="<?php echo $image['alt']; ?>" <?php if ($width < $height){ ?>class="portrait"<?php } else {?>class="landscape"<?php } ?> /> ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
Any idea what is wrong with the code? It seems like the <?php echo $image[‘sizes’][ $size . ‘-width’ ]; ?> is not working
Nevermind this worked
<?php
$url = $image['url'];
$width = $image['width'];
$height = $image['height'];
?>