Instantly share code, notes, and snippets.

@billerickson /post.php Secret
Created Oct 24, 2018

Embed
What would you like to do?
<?php
add_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
add_action( 'genesis_post_content', 'genesis_do_post_image' );
/**
* Echo the post image on archive pages.
*
* If this an archive page and the option is set to show thumbnail, then it gets the image size as per the theme
* setting, wraps it in the post permalink and echoes it.
*
* @since 1.1.0
*/
function genesis_do_post_image() {
if ( ! is_singular() && genesis_get_option( 'content_archive_thumbnail' ) ) {
$img = genesis_get_image( array(
'format' => 'html',
'size' => genesis_get_option( 'image_size' ),
'context' => 'archive',
'attr' => genesis_parse_attr( 'entry-image', array(
'alt' => get_the_title(),
) ),
) );
if ( ! empty( $img ) ) {
genesis_markup( array(
'open' => '<a %s>',
'close' => '</a>',
'content' => wp_make_content_images_responsive( $img ),
'context' => 'entry-image-link',
) );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment