Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created October 24, 2018 20:27
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 billerickson/b75b66c3ad2b386048fdc60ba8927441 to your computer and use it in GitHub Desktop.
Save billerickson/b75b66c3ad2b386048fdc60ba8927441 to your computer and use it in GitHub Desktop.
<?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