One of the latest themes from Genesis has the ability to show the featured image that is set to appear at the top of a post or page, the setting is shown in the Customizer and is enabled by default – here is how you can use this in any Genesis theme.

show-featured-image-post-page

It is best to modularize the customizer and image functions into respective files but you can add the whole thing in functions.php.

Add the Customizer Fields and Settings

So add in the Customizer controls

View the code on Gist.

Add in the function to add the Featured Image

View the code on Gist.

If you wanted the image to appear before the header you would change the add_action hook to genesis_entry-header

Doing It Alone

If you didn’t care about the customizer control you can just add the featured image to the post with this amended snippet…

View the code on Gist.

Using Custom Image Sizes

For any image sizes outside of thumbnail, medium or large you need to pass in the size and crop values in an array like this…

size => array(300, 450, true),

So you pass in widthheight and whether or not to hard crop; true for yes and false for no.

Share:

Leave a Reply