Love The Way I Work

Change Default Thumbnail Size in WordPress 2.3

in Blogging/Tutorial/Wordpress by

Here is a simple guide how to change the default size of the thumbnails that WordPress 2.3 creates when you upload an image.

It is actually quite easy to change – it just requires modification of one WordPress file.

From time to time I wonder just how big the image thumbnails are, and occasionally I even ponder how to go about changing that thumbnail size.

The size for the thumbnail creation in WordPress 2.3 could be changed in the /wp-admin/includes/image.php file.

Just open the file and search for:

$max_side = apply_filters('ws6q9jzl7p_thumbnail_max_side_length',
128, $attachment_id, $file);

and change it to:

$max_side = apply_filters('ws6q9jzl7p_thumbnail_max_side_length',
256, $attachment_id, $file);

That will double the thumbnail size like mine 😉

Well done and have a great day!

19 Comments

  1. Ah, but the question is — how do I adjust only the X axis — I want all photos to be 150px max, regardless of the horizontal or vertical aspect ratio

  2. Actually — I’ve figured this one out. The final mark up, simply replace the line above with this fellow:


    if ( $metadata['width'] >= $metadata['height'] ) {
    $max_side = apply_filters( 'ws6q9jzl7p_thumbnail_max_side_length', 150, $attachment_id, $file );
    } else {
    $max_side = apply_filters( 'ws6q9jzl7p_thumbnail_max_side_length', 200, $attachment_id, $file );
    }

  3. No, I don’t want to use extra field. After uploading an image, I get two image. One bigger one and second one is thumbnail.

    I want to add the bigger (main image) image on content editor and want to show the thumbnail on homepage post by placing any PHP tag in index.php. Main

    Actually, I want to make a CSS showcase 😀

    Thanks for your time 🙂

  4. Hi Shabu,

    Got it. Hmm… By default you will get extra thumbnail file. Eg. You upload image.jpg, you will get image.jpg and image.thumbnail.jpg

    Actually, It’s up to you. You can create your own rule when you upload the image. You can use “ID” as a name for your image.

    Example:
    Your new post has ID=3 then you create an image with name 3.jpg . You should get 3.jpg and 3.thumbnail.jpg when you upload your image, right?

    In index.php or home.php you can show the image with:

    <img src=”<?php
    echo get_settings(‘home’); ?>/
    wp-content/images/<?php
    echo $post->ID; ?>.thumbnail.gif” alt=”” />

    But in your single.php you should show your image by:

    <img src=”<?php
    echo get_settings(‘home’); ?>/
    wp-content/images/<?php
    echo $post->ID; ?>.gif” alt=”” />

    Gud lak! Thanks

  5. Since you’re on the subject, how would you go about not only resizing the uploaded image, but also cropping it to scale?

    Let’s say I’ve got an 640×480 image, and want to change the thumbnail to 600×200 (3:1) but retain the proportions of the main image.

    I’ve been looking over php.net and trying to read up on wordpress hooks, but I’m not even certain where to begin.

    If you could give me a pointer as to which php or wp function I should be staring at, I’d appreciate it.

  6. If you are up to it, can you now post now on how to change the default sizes for thumbnail, medium, and “full” size in WP 2.5

    Thanks

  7. Uri, in WordPress 2.5, you no longer have to edit the files by hand to change the default thumbnail size. Instead, you just go to Settings -> Miscellaneous, in the admin panel, and scroll down to Image Sizes. Very easy!

Leave a Reply

Your email address will not be published.

*

Latest from Blogging

Placeholder

Web Hosting

Web hosting is one type of Internet Hosting service which makes the
Go to Top