Skip to content

Instantly share code, notes, and snippets.

@chekle
Last active November 20, 2023 03:08
Show Gist options
  • Save chekle/78af18c95889da42869c66e1ea4be38f to your computer and use it in GitHub Desktop.
Save chekle/78af18c95889da42869c66e1ea4be38f to your computer and use it in GitHub Desktop.
ACF Images Using ID
URL
<?php $image = get_sub_field('image'); $size = 'medium'; if( $image ) { echo wp_get_attachment_image_url( $image, $size ); } ?>
IMG
<?php $image = get_sub_field('image'); $size = 'full'; if( $image ) { echo wp_get_attachment_image( $image, $size ); } ?>
IMG w Class
<?php $image = get_sub_field('image'); $size = 'full'; if( $image ) { echo wp_get_attachment_image( $image, $size, "", array ('class' => 'rounded-4 mb-4' ) ); } ?>
FIGURE / IMG
<?php $image = get_field('banner_image'); $size = 'full'; if( $image ) { ?>
<figure>
<?php echo wp_get_attachment_image( $image, $size ); ?>
</figure>
<?php } ?>
PICTURE / IMG
<?php $image = get_field('image'); $size = 'full'; if( $image ) { ?>
<picture>
<?php echo wp_get_attachment_image( $image, $size ); ?>
</picture>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment