Image dimensions same as image size

So if I set the large image size in the media library to say 600×600 pixels, and then upload an image which is the same dimensions it won’t get set as the ‘large’ image.

There is talk on this question about it being the ratio, but I don’t think this is the case. Also I don’t want to setup another custom image size as its will just bloat the server with redundant images, when ‘large’ should work!

Is there a filter or setting where I can change the logic of the images, so if the dimension is larger than , OR equal to the media library setting it gets set as the large image. At the moment the equal to seems to be missing.

Thanks

2 Answers
2

No, it won’t create a new image that is exactly the same size.. nor should it. All the thumbnail, medium, and large images are resized images, by definition. Since the original image is already 600×600, there’s no point in creating another file at the same size, but with a lower quality (remember that JPEG compression is lossy).

However, if you specify in the template call that you want to use the large image size with something like <?php echo get_the_post_thumbnail( $post->ID, 'large' ); ?>, and there is no “large” size available for that image, then it will actually use the full sized image, not the medium sized one. It always chooses “up”, basically.

See, whenever you specify an image size like large or medium or even array(400,400), then what WordPress does is to pick the next larger size image that it can find and then it uses that, along with width/height rules in the IMG tag to make the browser resize it down. It does this because images look like crap when sized up, but reasonably okay when sized down.

So yes, even without the large image size being created, specifying the “large” size as a size in the template is okay and will work correctly. I’ve just tested this on a test site, using this exact code and sizing, and it works properly. Specifying the large size made it actually use the URL of the full size, not the medium one.

Leave a Comment