Created
October 2, 2012 16:22
-
-
Save mintindeed/3820638 to your computer and use it in GitHub Desktop.
AL get_hero_image() usage
This file contains hidden or 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 | |
$args = array( | |
'post_id' => get_the_ID(), | |
'size' => 'article-hero' | |
); | |
$hero_image = PMC_Awardsline::get_hero_image( $args, 'featured', 'array' ); | |
if ( $hero_image ) { | |
?> | |
<figure class="a-center"> | |
<img src="<?php echo esc_url( $hero_image['src'] ); ?>" width="602" height="360" alt="<?php echo esc_attr( $hero_image['alt'] ); ?>" /> | |
<?php if ( $hero_image['caption'] ) { ?> | |
<figcaption><?php echo $hero_image['caption']; ?></figcaption> | |
<?php } ?> | |
</figure> | |
<?php | |
} | |
/* | |
PMC_Awardsline::get_hero_image(...) | |
returns false if no image is found | |
returns object/array with all required fields | |
$hero_image = array( | |
'ID' => ..., // name matches WP standards | |
'src' => ..., | |
'width' => ..., // return the image's natural width | |
'height' => ..., // return the image's natural height | |
'html' => ..., // Simplify the function by always generating the HTML markup | |
'alt' => ..., // get_hero_image() should handle all the boilerplate for getting the alt text | |
'caption' => ..., // get_hero_image() should handle all the boilerplate for getting the caption | |
); | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment