Media > Image Sizes aren’t being applied to uploads

The issue is that WordPress always maintains the aspect ratio on your photos. For a lot of uses, this makes sense. However, if you’re trying to line up a bunch of images — some in portrait, others in landscape — it can be a real pain.

If you want to fix this, you can register a new image size in your functions.php file in your theme. For example, I just added:

add_image_size('yourName', 400, 400, true);

The function is defined as follows in /wp-includes/media.php:

function add_image_size( $name, $width = 0, $height = 0, $crop = false ) {
    global $_wp_additional_image_sizes;
    $_wp_additional_image_sizes[$name] = array( 'width' => absint( $width ), 'height' => absint( $height ), 'crop' => (bool) $crop );
}

You can then ask for the image by using:

the_post_thumbnail('yourName');

inside of your theme… but this only works for the featured image. Sadly, the image size option isn’t added to the selection box when adding media through the backend.

Also, if this does what you’re looking for, you can auto-resize any old images you have to the new size by using this plugin: http://wordpress.org/extend/plugins/regenerate-thumbnails/

Leave a Comment