Wordpress - Post Thumbnails and add_image_size
Want more control over post thumbnails in your Wordpress posts and pages? Simple! Use the default theme 'TwentyTen' for this example..
In your page.php/single.php as an example, whilst in the loop, pop in the_post_thumbnail() - This will display the thumbnail specified when you add a Featured Image when creating your new post. By default, this will output a 'thumbnail' size image as specified in your media settings, in the Wordpress admin. But what if you want to change the size of this in your code..? Read on..
Change the thumbnail size
To change the thumbnail size, open up functions.php, and at the bottom.. you need to enter the following code...
add_image_size(thumbname, width, height, crop)
The above code, change the attributes to what is needed. So for example, if I needed a thumbnail in my posts, with a width of 200 x 100, which is hard cropped, I would use:
add_image_size('mynewsize', 200, 100, true) <-- for crop, use true or false.. true will hard crop...
Notice we have specified 'mynewsize' as the new thumbnail size... now, all we have to do is pop in, or amend the code in single.php/page.php to this:
This will create the thumbnail to the size specified in functions.php.