Header Image

Ignition comes with an ACF field that adds a second featured image field. It appears on every post type and is very useful. It allows you to show a different image for the single view so you can have one image for the card view, and one for the single view.

Ignition comes with a function for showing the header image. The following function will get the url, of the image. It also goes through wordpress‘ hooks and filters so if you have any plugins that affect the images like WP Retina, they will work correctly. 

echo ign_get_header_image($post_id);

This will output the url to the image. You probably want to use this to show the header image as a background image. You can see it in use in any of the header section files found in template-parts/blocks.

You can also get the image as an html image by adding the second parameter. In fact here is the full function.

function ign_get_header_image($post_id, $return_type = 'url', $attr = ''){
	if( get_field('no_image', $id) ){
		return '';
	}

	$image = get_field('header_image');
	if($kind == 'url'){
		return ign_get_the_image_url($id, 'header_image', $image);
	}
	else{
		return ign_get_the_image($id, 'header_image', $image, $attr);
	}
}

As you can see, you can pass anything other than ‘url‘ to get the actual image tag. You can also pass an array of attributes that will be passed to the image when doing it this way.

This function is just getting the other two media functions that come with Ignition. One get’s the url to a custom image field. The second one gets the image html markup. Both these function are great for getting an image field made with ACF.