Skip to content

Instantly share code, notes, and snippets.

@hellofromtonya
Created March 5, 2015 05:07
Show Gist options
  • Save hellofromtonya/4a991636167fd8623d56 to your computer and use it in GitHub Desktop.
Save hellofromtonya/4a991636167fd8623d56 to your computer and use it in GitHub Desktop.
Add an icon to the featured image HTML - Genesis
<?php namespace tonya;
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
add_action( 'genesis_entry_header', 'tonya\do_post_grid_image', 1 );
/**
* Echo the post image
*
* @since 1.1.0
*
* @uses render_post_featured_image()
*/
function do_post_grid_image() {
if ( ! is_singular() && genesis_get_option( 'content_archive_thumbnail' ) ) {
\tonya\render_post_featured_image( 'grid_thumbnail', 'grid-thumbnail' );
} else {
\tonya\render_post_featured_image( 'post_featured_image', 'post-featured-image' );
}
}
/**
* Adds the respective icon to the image's HTML
*
* @since 1.0.0
*
* @param string $size
* @param string $class
* @return void
*/
function render_post_featured_image( $size, $class ) {
$img = genesis_get_image( array(
'format' => 'html',
'size' => $size,
'context' => 'archive',
'attr' => genesis_parse_attr('entry-image'),
));
if ( ! empty( $img ) ) {
$icon = 'icon-large-' . get_post_type( get_the_ID() );
echo apply_filters( 'tonya_post_grid_image_filter',
sprintf( '<div class="%s"><a href="%s" title="%s"><span class="%s"></span>%s</a></div>',
esc_attr( $class ),
get_permalink(),
the_title_attribute( 'echo=0' ),
$icon,
$img
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment