WordPress.org

Ready to get started?Download WordPress

Forums

Changing Image Thumbnail Upload Size (simple hack) (3 posts)

  1. jestep
    Member
    Posted 7 years ago #

    I couldn't find an answer on how to change the size of image thumbnails once you upload them, so i figured out how to do it on my own. All you have to know is what dimension you one your thumbnails to be and wordpress does the rest.

    Really Simple fix that involves changing 2 lines in the admin-functions.php file. In my case I wanted all my thumbnails to be 250px on their largest side.

    Open the wp-admin/admin-functions.php file and find:
    $image_new_width = $max_side;

    change to:
    $image_new_width = 250;

    next find:
    $image_new_height = $max_side;

    change to:
    $image_new_height = 250;

    Upload the file to the server and that's it. I hope this isn't covered somewhere else, but I could not find it anywhere. Change the 250 to whatever you want your thumbnails to be.

  2. geoffe
    Member
    Posted 7 years ago #

    even more effective is to find where the wp_create_thumbnail function is called (inline-uploading.php), then change the number that is sent in the $max_side variable.

    This way, you can avoid messing with the dynamic resizing based on the dimensions of the input image. With your method, an image with the largest edge of 200px will be scaled up to 250px.

    To explain further, notice the order of the variables in the function wp_create_thumbnail($file, $max_side, $effect = '') The second number is the max_side where it is called in inline-uploading.php as
    $thumb = wp_create_thumbnail($file, 128);
    That 128 is your $max_side.

    You'll also see that the function tests if the image is larger than 128 pixels before calling a thumbnail of 128 pixels on the longest side. You'll want to edit that to 250 as well.

  3. scottmotte
    Member
    Posted 7 years ago #

    inline-uploading.php no longer exists in the newest version of WordPress. You need to do as geoffe described but in "admin-functions.php". It is line 2118 in my version of wordpress.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags