WordPress.org

Ready to get started?Download WordPress

Forums

Resize Image After Upload
[resolved] Misses Square Images (Plus Another Situation) (2 posts)

  1. maryjanesfarm
    Member
    Posted 1 year ago #

    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!

    https://wordpress.org/plugins/resize-image-after-upload/

  2. iamphilrae
    Member
    Plugin Author

    Posted 5 months ago #

    Hi,

    Sorry for the delay but this should now be resolved in v1.6.

    Kind regards
    Phil

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic