Created
October 17, 2018 15:53
Star
You must be signed in to star a gist
Example passing optional $args
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @param array $args | |
* | |
* @return string | |
*/ | |
function get_banner_image_html( $size = 'medium', $args = array() ){ | |
$args = array_merge( array( | |
'before' => '<figure class="show__banner-image">', | |
'after' => '</figure>', | |
'empty' => '' | |
), $args ); | |
$html = ''; | |
if( !$image_id = $this->banner_image_id() ){ | |
$image_id = $this->featured_image_id(); | |
} | |
if( $image_id ){ | |
$html = wp_get_attachment_image( $image_id, $size, false, $args ); | |
} else { | |
$html = $args['empty']; | |
} | |
return $html ? "{$args['before']}{$html}{$args['after']}" : '' ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment