Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

  • Thumbnail size: 170x80

  • Medium size: 550x170

  • Large size: 550x320

  • ("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 550x320 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: 137x80

  • Medium size: 292x170

  • Large size: (unavailable)

  • Original size: 550x320

How can I get these image sizes working correctly?

share|improve this question
    
Just to get more info: are you trying to do this on a one-image-per-post basis, or more of a random number of images inside of posts? In other words, are you trying to use the "Add an image"/"Media Gallery" feature inside of the new page/post view, or something like the Featured Image feature? –  Gavin Anderegg Mar 25 '11 at 1:31
add comment

1 Answer

up vote 5 down vote accepted

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/

share|improve this answer
    
Perfect - thank you! –  Ryan Mar 25 '11 at 17:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.