Create Custom Image Sizes For Your WordPress Theme

Create Custom Image Sizes For Your WordPress Theme

When uploading into wordpress,it automatically generate other image sizes with uploaded. The default image sizes are setup on the settings -> media screen. create_custom_images     Wordpress by default allow you to use only 3 image size i.e thumbnail,medium,large,If need more images to use you can use following php coding into your functions.php inside theme folder It uses the WordPress function add_image_size to add a new image size to your WordPress theme.

     if ( function_exists( 'add_image_size' ) ) {
	add_image_size( 'custom-image-size1', 300, 9999 ); //300 pixels wide (and unlimited height)
	add_image_size( 'custom-image-size2', 220, 180, true ); //(cropped)
     }
use the function the_post_thumbnail() to use this image on page . Now we can pass this params into the function to display the image because  we have named the image as custom-image-size1.
if ( has_post_thumbnail() ){
    the_post_thumbnail( 'custom-image-size1' );
}