Skip to content

Instantly share code, notes, and snippets.

@mintindeed
Created October 2, 2012 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mintindeed/3820638 to your computer and use it in GitHub Desktop.
Save mintindeed/3820638 to your computer and use it in GitHub Desktop.
AL get_hero_image() usage
<?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