强制WordPress创建图像缩略图

Currently, lines 378 -380 of media.php contains this line:

// if the resulting image would be the same size or larger we don't want to resize it
if ( $new_w >= $orig_w && $new_h >= $orig_h && !$allow_resize)
    return false;

That obviously makes a lot of sense for a typical setup, but I'm working on a photography site where admin will be uploading very high-quality JPGs that are the right dimensions for the Large size thumbnail, but the image quality is too high for web use.

Essentially, I'd like WordPress to create a large thumbnail that's the same size as the original (which the core code prevents it from doing). I've seen a few solutions floated around, but they all involve replacing and destroying the original, which I don't want to do.

Any tips on where to start?

Try this in your functions.php of your theme:

add_filter('image_resize_dimensions', 'filterCompress', 1, 6);

function filterCompress($foo, $orig_w, $orig_h, $dest_w, $dest_h, $crop) {
  if ( $orig_w == $dest_w && $orig_h == $dest_h ) {
        return array( 0, 0, 0, 0, (int) $orig_w, (int) $orig_h, (int) $orig_w, (int) $orig_h );
  }
  return null;
}

I did this based on WordPress 3.5.1, based on your question I'm assuming you are using a different version but it still might work.