Ashley Cameron Design

Ashley Cameron Design

Shop the Creative Design Market

Good morning

Add custom images sizes to WordPress

SnippetsWordPress

About a 1 minute read

"If you truly love nature, you will find beauty everywhere."

Vincent Van Gogh


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') );