Getting a Image Size URL from the Advanced Custom Fields Image Field

On a recent WordPress project, I often found myself needing to get an image size URL an image uploaded via Advanced Custom Field’s image field.

The ACF image field allows you to return either the URL of the full-sized image, the image (attachment) ID, or the image object. How you configure this will depend on the method you intend to use to retrieve the URL.

Using wp_get_attachment_image_src

For this method, you’ll want to return the image ID. To get the image URL, we’ll use the following code:

Using the Image Object

You can also configure ACF to return the image object and extract the image URL like so:

One thought on “Getting a Image Size URL from the Advanced Custom Fields Image Field

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>