Skip to content

Instantly share code, notes, and snippets.

@brianpurkiss
Created April 3, 2019 15:13
Show Gist options
  • Select an option

  • Save brianpurkiss/c5582eecefaf29c70a4007635e3486b0 to your computer and use it in GitHub Desktop.

Select an option

Save brianpurkiss/c5582eecefaf29c70a4007635e3486b0 to your computer and use it in GitHub Desktop.
Get correct size of ACF Image
<?php $image = get_field('img');
if( !empty($image) ) :
$alt = $image['alt'];
$size = 'large';
$img_url = $image['sizes'][ $size ]; ?>
<img src="<?php echo $img_url; ?>" alt="<?php echo $alt; ?>" />
<?php endif; ?>
<?php // more info: https://www.advancedcustomfields.com/resources/image/ ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment