Say "Hello!"

  • This field is for validation purposes and should be left unchanged.

Add custom images sizes to WordPress

Web Hosting at Bluehost Affiliate Disclosure

1
2
3
4
5
6
7
8
9
10
11
12
// Add Feature Image size, hard crop
if ( function_exists( 'add_image_size' ) ) {
     add_image_size( 'feature-image', 570, 285, true );
     add_image_size( 'feature-image-small', 285, 285, true);
     add_image_size( 'feature-image-home', 285, 303, true);
}

// To use the image, if feature image exist
if ( has_post_thumbnail() ) { the_post_thumbnail( 'feature-image' ); }

// Add a class to the image
echo the_post_thumbnail( 'feature-image-large', array('class' => 'feature-image') );

Back to Snippets Follow me on GitHub

Ashley Cameron logo
Blog