Skip to content

Instantly share code, notes, and snippets.

@dustinleer
Last active April 28, 2022 14:23
Show Gist options
  • Save dustinleer/78c5d804dac8ea87af5c1862b5dc2dfa to your computer and use it in GitHub Desktop.
Save dustinleer/78c5d804dac8ea87af5c1862b5dc2dfa to your computer and use it in GitHub Desktop.
Uses default wp_get_attchment for image with ACF
<?php
$image = get_field('acf_field_name', 'options');
if( !empty( $image ) ) {
$image_id = $image['ID'];
$alt = $image['alt'];
$alt = $image['alt'] ? $image['alt'] : $image['title'];
$size = 'medium'; // (thumbnail, medium, large, full or custom size)
echo wp_get_attachment_image(
$image_id,
$size,
false,
array(
'class' => 'image_class',
'alt' => $alt,
)
);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment