Custom Thumbnail Sizes in WordPress

If you’re uploading pretty big images for full-width post thumbnails or large post background images then resizing the thumbnails for use on other parts of the site is a must.

Let’s say, for example, your post thumbnails are 900px wide. You don’t want them that big for performance reasons if they’re only going to be shown at 300px wide (maximum). Here’s how to resize (this does leave an unlimited height which is proportional to the original size):

add_image_size('post-thumb-mini', 150);
add_image_size('post-thumb-small', 300);
add_image_size('post-thumb-medium', 600);

You can also crop the thumbnail to the desired size if unlimited, proportional height isn’t what you’re after.

add_image_size('post-thumb-mini', 300, 200, true); // Hard crop mode
add_image_size('post-thumb-mini', 300, 200); // Soft crop mode

Hard Crop Mode

This cuts the image off at the specified height and doesn’t crop proportionally. If you specify 300, 200, true it will be shown at exactly that size.

Soft Crop Mode

This proportionally resizes the image and doesn’t cut off or distort any part of the image. If you specify 300, 200 it will be shown at roughly that size

Follow IP on Twitter Like IP on Facebook

Advertisement