get ACF image size URL by image object
This file contains 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 | |
// first, get the image object returned by ACF | |
$image_object = get_field('my_image_field'); | |
// and the image size you want to return | |
$image_size = 'thumbnail'; | |
// now, we'll exctract the image URL from $image_object | |
$image_url = $image_object['sizes'][$image_size]; | |
?> | |
<img src="<?php echo $image_url; ?>" alt=""> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment