0

I have a news blog created on WordPress. I've set up WordPress to create 3 resized versions of images when uploading them.

  • 315x215(featured image with cropping option enabled)

  • 620x (to create images by width and set up height automatically depending on image)

  • 900x (the same, but larger for gallery)

  • original image(it is being saved automatically)

    When I uploaded some images Ive noticed that WordPress creates

  • 300x250 or 216...,

  • 315x215

  • 620x

  • 900x images (and of course original)

WHY does WordPress create 300x size image??? Recently I removed 900x image option because I don't use it anymore, and after that WordPress does the same but instead of making unused 315x image now it creates additional image of 620 width which is being cropped by height (for example, normal 620x396 and cropped 620x350). Now the 315x images are generated without unused 300x, but the same problem is with 620x. Using WordPress 3.5.1 (but the problem was from the start- 3.4).

Update:

I am using this code in functions.php

add_theme_support('post-thumbnails');   
set_post_thumbnail_size(315, 215, true);        
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10, 3 );

function remove_thumbnail_dimensions( $html, $post_id, $post_image_id ) {
    $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
    return $html;
}

I've set up WordPress to create 3 resized versions of images by going to Media Options and pointing 315x215 in featured image options and checked Crop featured image option, 620x0 for medium size and 900x0 for large size(the last one 0x0 now, I just don't need it anymore)

Update 2:

Sorry Michael, but You didn't understand. I WANT WordPress to automatically generate different sizes of images(315x215 for thumbnails 620x for medium size images). I have adjusted the sizes in Dashboard -> Settings -> Media -> Image Sizes like that. What I DON'T want WordPress to do is to generate two images with width 620px and different heights (often or always it is 620x350 and 620x348). It's some kind of bug or something I think, an intermediate image left by WordPress after generating sizes. Will really appreciate if someone helps.

6
  • How did you set up WordPress to create 3 resized versions of images? Feb 18, 2013 at 12:10
  • Please deactivate all your plugins and then try again. Probably just a plugin doing that. @VinodDalvi add_image_size().
    – kaiser
    Feb 18, 2013 at 12:20
  • @Kaiser i know add_image_size() function is used for that. i wanted to know whether he is using this function in theme or or using any plugin? Feb 18, 2013 at 12:23
  • 1
    Also make sure the 300px image is not just the default medium sized one. 300x600 cropped is the default settings for the medium image size.
    – Simon
    Feb 18, 2013 at 12:47
  • Will anybody help?
    – user27644
    Feb 18, 2013 at 14:57

1 Answer 1

2

By default, WordPress will automatically generate a few different sizes of images. You can adjust the sizes here: Dashboard -> Settings -> Media -> Image Sizes.

If you want to prevent certain image sizes from generating upon your uploaded images, you could use the filter intermediate_image_sizes to remove the generation of certain image sizes.

Example

function mbe_filter_image_sizes($sizes){
    unset($sizes['thumbnail']);
    unset($sizes['medium']);
    unset($sizes['large']);
    return $sizes;
}
add_filter('intermediate_image_sizes', 'mbe_filter_image_sizes');

If you wanted to add your own image sizes you could do so using the function add_image_size();

Example :: Fixed Width and Unlimited Height

add_image_size('f_width_u_height', 620, 9999);

Example :: Fixed Height and Unlimited Width

add_image_size('f_height_u_width, 9999, 620);

Example :: Fixed Width and Fixed Height

add_image_size('f_width_f_height, 620, 620, true);

Note: If you want the changes to reflect upon existing images, you will need to either re-upload the images or, use a plugin.

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.