Exact image sizes

You’ll want to use add_image_size() in your functions.php to tell WordPress you’d like it to create a new image size when you upload images:

add_image_size( 'custom_image_size_name', 290, 180, true );

Using the value true will tell WordPress you want it to crop the image to those exact dimensions.

Once you do that and upload an image, you can use 'custom_image_size_name' in wp_get_attachment_image() to get the correct image.

Because WordPress only creates the image sizes when you upload images, you’ll want to use a plugin like AJAX Thumbnail Rebuild to rebuild previously uploaded images with your newly defined images size.

Leave a Comment