how to get image size url with acf

Get A Specific Image Size URL From An ACF Image Field

By default an Advanced Custom Fields Image object will return the full sized image. But what if you want a specific image size.

Here is how you can get a specific image size url from an ACF image field.

If your acf image field is returning an image object, then you can use code similar to this to get the url for a specific image size.


// 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="">

Leave a Reply

Your email address will not be published. Required fields are marked *