2

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?

1
  • 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? Mar 25, 2011 at 1:31

1 Answer 1

6

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/

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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