Viewing 1 replies (of 1 total)
  • Thread Starter alains

    (@alains)

    Ok WP folks…I’ve figured it out after many tests.

    This solution is for everyone that wants all thumbs be max. xxx width… no matter if image is 2:10 in proportion.

    Replace my 120 value with width of your choice.

    Her we go:

    In inline-uploading.php comment out this:


    if ( $imagedata['width'] * $imagedata['height'] < 4 * 1024 * 1024 ) {
    if ( $imagedata['width'] > 120 && $imagedata['width'] >=

    $imagedata['height'] * 0.2 )
    $thumb = wp_create_thumbnail($file, 120);
    elseif ( $imagedata['height'] > 150 )
    $thumb = wp_create_thumbnail($file, 150);

    if ( @file_exists($thumb) ) {
    $newdata = $imagedata;
    $newdata['thumb'] = basename($thumb);
    update_post_meta($id, '_wp_attachment_metadata', $newdata,

    $imagedata);
    } else {
    $error = $thumb;
    }
    }

    and replace it with:

    if ( $imagedata['width'] * $imagedata['height'] < 4 * 1024 * 1024 )
    {
    if ( $imagedata['width'] > 120 )
    $thumb = wp_create_thumbnail($file, 120);

    if ( @file_exists($thumb) )
    {
    $newdata = $imagedata;
    $newdata['thumb'] = basename($thumb);
    update_post_meta($id, '_wp_attachment_metadata',

    $newdata, $imagedata);
    }
    else { $error = $thumb; }
    }

    then go to admin-functions.php and comment out this portion of code:

    if ($image_attr[0] > $image_attr[1]) {
    $image_width = $image_attr[0];
    $image_height = $image_attr[1];
    $image_new_width = $max_side;

    $image_ratio = $image_width / $image_new_width;
    $image_new_height = $image_height / $image_ratio;
    //width is > height
    } else {
    $image_width = $image_attr[0];
    $image_height = $image_attr[1];
    $image_new_height = $max_side;

    $image_ratio = $image_height / $image_new_height;
    $image_new_width = $image_width / $image_ratio;
    //height > width
    }

    add this instead:

    $image_width = $image_attr[0];
    $image_height = $image_attr[1];
    $image_new_width = $max_side;

    $image_ratio = $image_width / $image_new_width;
    $image_new_height = $image_height / $image_ratio;

    That’s it. Now all thumbnails will follow the 120 max width rule. Just replace 120 with width of your choice.

    I think that this post can be marked as resolved ??

    It’s really interesting that finding a solution to this problem was really a pain in the ass. I was able to find solutions and help on this forum to more obscure problems.

    Thmubs up for integrating thumbnail handling in next release of WP – the greatest tool that web ever seen.

Viewing 1 replies (of 1 total)
  • The topic ‘Thumbnail size – width priority’ is closed to new replies.