Featured Image in Genesis Theme – Best Practice


Have you checked whether your site images are showing in google image search result?

I recently checked and found that, all images are showing up! But, NO images are showing when I searched for large images.

After a comprehensive study we narrowed down few best practices.

1. What should be the Featured Image size?

Featured Image dimension should be 1280 x 720 pixel. Google treats images having minimum dimension of 1280 by 720 pixel as large image.

2. Set a Default Featured Image

add_filter( 'genesis_get_image_default_args', 'wbxp_fallback_featured_image' );
function wbxp_fallback_featured_image( $defaults ) {
	$defaults[ 'fallback' ] = 18853; // attachment ID of the default image
	return $defaults;
}

After setting up the default featured image we got the following result:


In the first post there is no featured image but it shows a default image. The second post has a featured image already set.

3. Set Media Settings properly

Any image when uploaded into wordpress, it will automatically creates few more instances of that image of different size based on media settings. Recommended media settings is shown below:


Thumbnail size: 160 x 90; Medium size: 640 x 360; Large size: 1280 x 720.

4. Regenerate Thumbnails

After saving the above settings, we need to regenerate the thumbnails. Simple use the plugin: Regenerate Thumbnails

5. Display featured image at Single posts/page

Add the following code into theme functions.php file.

add_action( 'genesis_before_entry', 'featured_post_image', 8 );
function featured_post_image() {
  if ( !is_singular( ))  return;
  the_post_thumbnail('large', ['class' => 'featured-image', 'title' => get_the_title()]);
}

Add the following into style.css for proper styling

.featured-image {
	margin-bottom: 30px;
}

Leave a Reply

Your email address will not be published.