WordPress already lets you specify different sizes for media files uploaded. The sizes thumbnail, medium and large are included and the image dimensions can be configured under the Tools > Media menu.
However, if you require more image sizes you can register them in functions.php using add_image_size():
if ( function_exists('add_theme_support') ) {
add_theme_support('post-thumbnails');
add_image_size("pinky", 100);
}
The first parameter of add_image_size
specifies the name of the image and next we specify the width. You can also set the height and there are cropping options too. Full details can be found on WordPress Codex.
The image can then be loaded using the_post_thumbnail()
function:
the_post_thumbnail("pinky");
Please note add_theme_support('post-thumbnails');
needs to supported by your theme for add_image_size
to work.
Regenarating Thumbnails
When you add a new image size you will need to regenerate your images otherwise older images will not have an image for the new image size created.
Luckily there is a fantastic WordPress plugin that does exactly that called, unsurprisingly, Regenerate Thumbnails.