Creating a new image size

Recently I found the need to make a new image size in WordPress, other than the usual “Thumbnail”, “Medium”, “Large”, and “Full”.

It’s not very difficult, you simply need to use the function add_image_size in your theme function file, a custom plugin, or an mu-plugins file.

It takes 4 options, 3 are required.  The first is the name of your new size.  This will never be front facing, so use something code-friendly.  Mine was homepage-slide.  Then it takes width and height.  The fourth parameter is whether you want to actually resize the original, or crop it to your new size.

My code looks like this:

if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'homepage-slide', 640, 427, false ); //( NOT cropped)
}

An additional problem that I ran into is that the client had already uploaded about 300 images.  This meant I needed to re-process all of them.

There are several good plugins that do this, but most of them want to do all of your images in one php run, which would time-out for me, since I had so many.

The plugin I used is called AJAX Thumbnail Rebuild. Rather than one big resize call it uses AJAX to make an individual call for each image.  It went through all 300 of my image no problem and then that image size was available to my code.

One comment

  1. Luke Rumley says:

    I had a very similar experience, though with many fewer images when a last-minute design change changed the size of some banner images. More than once. Grr.

    I used a PHP regenerator, and was happy with the results as well.

    Does StartBox provide a function for this? Genesis does, though now that I see how simple it was, I am not sure why:

    genesis_add_image_size(‘Homepage Banner’, 920, 300, TRUE);

Leave a Reply

Your email address will not be published. Required fields are marked *