Media > Image Sizes aren’t being applied to uploads

Under Media Settings I edited the Image Sizes to the following:

  • Thumbnail size: 170×80

  • Medium size: 550×170

  • Large size: 550×320

  • (“Crop thumbnails to exact dimensions” is checked)

  • Maximum embed size: Width 1000, Height 1000

My problem is when I upload an image it ignores these dimensions. For example, when I upload a 550×320 image, and then try to add it to a post, it has been cropped to the following sizes (uploads folder shows the same):

  • Thumbnail size: 137×80

  • Medium size: 292×170

  • Large size: (unavailable)

  • Original size: 550×320

How can I get these image sizes working correctly?

1 Answer
1

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