Skip to content

Instantly share code, notes, and snippets.

@zenman
Created February 19, 2014 18:26
Show Gist options
  • Save zenman/9098305 to your computer and use it in GitHub Desktop.
Save zenman/9098305 to your computer and use it in GitHub Desktop.
ACF, display image only if there is one, include the alt title. Ensure the filed type in ACF is "Image Object"
<?php $img = get_field('FIELD_NAME_HERE'); if($img): ?>
<img src="<?php echo $img['url']; ?>" alt="<?php echo $img['alt']; ?>">
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment