Returns the header image as a url. It can also return an html image. This gets the header image from the header image field that comes with ignition. If it does not find an image, it will fallback on the featured image.
This field is a shortcut to using either ign_get_image_url() or ign_get_image() depending on the parameters. However it is only for the header image, as it only looks for the header image custom field.
Parameters
$post_id: (integer) The post_id for where to get the custom field. By default it is the current post.
$return_type: (string) If the string is anything but ‘url’ it will return the actual html image instead. By default it is set to ‘url’
$attr: (array) Array of attributes to add to the html image markup. This will only apply if the $return_type is not ‘url’.
File: inc/template-tags.php
function ign_get_header_image( $post_id = 0, $return_type = 'url', $attr = '' ) {
if ( ! $post_id ) {
global $post;
$post_id = $post->ID;
}
if ( function_exists( 'get_field' ) ) {
if ( get_field( 'no_image', $post_id ) ) {
return '';
}
$image = get_field( 'header_image', $post_id );
}else{
$image = '';
}
if ( $return_type == 'url' ) {
return ign_get_image_url( $image, $post_id, 'header_image', true );
} else {
return ign_get_image( $image, $post_id, 'header_image', $attr, true );
}
}