Using Additional Thumbnail Sizes in WordPress

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_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:


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.

This entry was posted in Programming and tagged . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

* = Required