Last active
April 12, 2018 02:25
-
-
Save rodgtr1/dca62763a15bb032867f976c4a94bcfc to your computer and use it in GitHub Desktop.
Display Featured Image & Custom Size - Genesis
This file contains 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
// Register a custom image size for Singular Featured images | |
//Choose custom image size and remember to Regenerate Thumbnails | |
add_image_size( 'singular-featured-thumb', 768, 450, true ); | |
//Hook to add image before entry content | |
add_action( 'genesis_before_entry_content', 'tm_display_featured_image' ); | |
//Function to display image | |
function tm_display_featured_image() { | |
if ( ! is_singular( array( 'post', 'page' ) ) ) { | |
return; //ends function if not singular post or page | |
} | |
if ( ! has_post_thumbnail() ) { | |
return; //ends function if no thumbnail chosen | |
} | |
// Display featured image above content | |
echo '<div class="singular-featured-image">'; | |
genesis_image( array( 'size' => 'singular-featured-thumb' ) ); | |
echo '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment