Custom Image Fields

If you ever make an image custom field with ACF, you may want to get that image and output it in your theme. This can be done easily, but getting the image without passing it through WordPress functions, means you won’t get any filters and hooks affecting it, which you probably want.

Ignition comes with two functions for easily getting an image. 

ign_get_image( $acf_image = '', $id = '', $size = '',  $attr = '', $use_thumbnail_as_fallback = false );

ign_get_image_url( $acf_image = '', $id = '',  $size = '', $use_thumbnail_as_fallback = false );

Both these functions can be found in inc/extras.php and are almost the same. They take the ACF image field, the image size and any attributes you may want to add.

The regular version will return an image tag. This version can also be passed image attributes, just like you would with get_the_post_thumbnail().

The second version returns a url. No attributes can be passed here. 

Both do have the ability to fallback on the featured image, if no image is found. By default it’s set to false.