• Resolved CameleonQc

    (@cameleonqc)


    Hello,

    I have set a maximum upload size already for our album users, but I need to set a minimum size to stop them uploading photos the size of a postage stamp.

    Would you have any suggestion on a way to implement that? Thank you!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Jacob N. Breetvelt

    (@opajaap)

    I will treat this as an enhancement request and implement it asap

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    Fixed 6.6.26:
    Table VII-B10 has been split into 10.1 and 10.2. 10.1 is new setting: Frontend upload min size.

    Thread Starter CameleonQc

    (@cameleonqc)

    Thank you so much, I really appreciate this. However, the way it is implemented is a bit restrictive for my intended use. It doesn’t matter with the max size if the value is the same for width and height. If it’s bigger than 3000px on any side, it’s too big, period.

    However, let’s say that I set min size at 2000px because I want to be able to display a high quality image from the album at full width on my home page (it’s a photo club). A user could upload an image of 2200 x 1800, for example which I could use, but the new function rejects it because one of the sides is “smaller” than 2000 x 2000. That’s the message it returns in such cases. I need an image with at least one side bigger than the min size in the settings to be accepted.

    I could try to go with a min value for the smaller size, hoping that the longer side will be over that value, but if someone uploads a panoramic image, for example, there is no way that I can guess the ratio to set a minimum height that would allow the desired width to be accepted as well… If I set my min at 1600 thinking that the width of a standard image should reach 2000, a panoramic image of 1600 x 5000 would then get rejected because of the max size… This pano would get accepted if only the size of the longer side could be set at a minimum of 2000 px and not its height.

    Is there a way to do that? Thank you so much, your service is fantastic!

    I’m learning to code, and I haven’t touched PHP yet, but I will this year, and I love looking at the changes you make. Great learning!

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    So, please tell me ‘your rules’ you want to see implemented. Both for minimum and maximum.
    Maybe something like this:

    min value: must be greater or equal to 300 x 400 or 400 x 300 pixels
    max value: must be smaller or equal to 2000 x 5000 or 5000 x 2000 pixels

    No problem to make it 4 values in stead of 2.
    It is a bit more coding, but that does not matter.

    Alternatively we could set a minimum and maximum to the product width * height, i.e. 120 kilo pixels and 10 mega pixels. Maybe a better idea ?

    Thread Starter CameleonQc

    (@cameleonqc)

    Sorry, there was a glitch and I replied twice.

    • This reply was modified 7 years, 10 months ago by CameleonQc.
    Thread Starter CameleonQc

    (@cameleonqc)

    For min value: I dont want to set a minimum for both sides of an image. Only the largest side.

    For example:
    width > 2000 or height > 2000

    For max, it doesn’t matter, it’s fin as it is.

    • This reply was modified 7 years, 10 months ago by CameleonQc.
    Thread Starter CameleonQc

    (@cameleonqc)

    OK, I found a way to do exactly what I want. I needed to change the operator || by && to apply the min value to only one of the two sides (either one). Then, the message needed to be modified accordingly.

    This is the modification I made to the code to make it work

    // Is it not too small?
    $ms = wppa_opt( ‘upload_frontend_minsize’ );
    if ( $ms ) { // Min size configured
    if ( $imgsize[0] < $ms && $imgsize[1] < $ms ) { // changed the logical operator
    $wppa_alert .= esc_js( sprintf( __( ‘Uploaded file is smaller than the allowed minimum of %d pixels on the longer side.’ , ‘wp-photo-album-plus’), $ms, $ms ) ); // changed the message
    return false;
    }
    }

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    Right. And in wppa-boxes.html around line 2476:

    
    '<div style="font-size:10px;" >' .
    	sprintf( __( 'Min photo size: %d x %d pixels', 'wp-photo-album-plus' ), $minsize, $minsize ) .
    '</div>';
    

    change to:

    
    '<div style="font-size:10px;" >' .
    	sprintf( __( 'Min photo size: %d pixels', 'wp-photo-album-plus' ), $minsize ) .
    '</div>';
    

    This together with your patch will be changed in the next version, and a few other textual changes.
    The readme will read:

    The minimum and maximum allowed fe upload image size works now as follows: an image is too small if both width and height are less than the given limit, the image is too large if either width or height (or both) is larger than the given limit.

    Thread Starter CameleonQc

    (@cameleonqc)

    Woohoo! I made my very first patch! LOL! Thank you very much for your help, it’s much appreciated.

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    Next time place code between backticks or use the code button.
    A block of code? first a backtick, code on next line and the closing backtick on a new line.

    Thread Starter CameleonQc

    (@cameleonqc)

    Got it, thank you! ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘How to set Users’ minimum upload size?’ is closed to new replies.