Support » Plugin: Resize Image After Upload » Misses Square Images (Plus Another Situation)

  • Resolved maryjanesfarm


    Hello, thank you for the plugin. I love it! It’s so very much going to help restrain the size of photos my users upload (dimensionally and filesize-wise).

    I did notice a situation where it didn’t work as expected. It missed square images, if their height was less than $max_height. In regards to that, my first suggestion for resize by width’s if condition is to change the > to >=.

    Also, in testing that and trying to work out more complex conditions, I noticed it would also not resize vertical images, if their width was greater than $max_width, but less than $max_height. To my mind, I want images to never violate the max width. That could very well not be the desired functionality for all situations, but nevertheless I propose the following changes overall:

    //Resize by width
    if(($original_width >= $original_height || ($original_height > $original_width && $original_width > $max_width)) && $max_width != 0) {
    	$objResize = new RVJ_ImageResize($array['file'], $array['file'], 'W', $max_width, true, $quality);
    //Resize by height
    if($max_height != 0) {
    	$objResize = new RVJ_ImageResize($array['file'], $array['file'], 'H', $max_height, true, $quality);

    Note that I changed the else if for resize by height to a simple if. It may mean, in some circumstances, that the image will be resized twice, but this way I think no dimension will ever violate one of the maximums. (If someone doesn’t like their image being resized twice, they should resize the durn thing properly before uploading to WordPress! 😉 )
    I tested it on a slew of images (horiz, square, vert; larger than max h/w, equal to, smaller than max h/w; some larger than both, some larger than max in only one dimension), in circumstances where $max_width > $max_height and where $max_width < $max_height.

    I still don’t know that I caught all possible combos, but let me know what you think.
    Thank you again!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Misses Square Images (Plus Another Situation)’ is closed to new replies.