Last active
April 28, 2022 14:23
-
-
Save dustinleer/78c5d804dac8ea87af5c1862b5dc2dfa to your computer and use it in GitHub Desktop.
Uses default wp_get_attchment for image with ACF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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