Dark

Light

Dark

Light

How to require minimum image upload dimensions condition for Woocommerce Products?

Add this code to your theme’s functions.php file, and it will limit minimum image dimentions

add_filter('wp_handle_upload_prefilter','tc_handle_upload_prefilter');
function tc_handle_upload_prefilter($file)
{

    $img=getimagesize($file['tmp_name']);
    $minimum = array('width' => '640', 'height' => '480');
    $width= $img[0];
    $height =$img[1];

    if ($width < $minimum['width'] )
        return array("error"=>"Image dimensions are too small. Minimum width is {$minimum['width']}px. Uploaded image width is $width px");

    elseif ($height <  $minimum['height'])
        return array("error"=>"Image dimensions are too small. Minimum height is {$minimum['height']}px. Uploaded image height is $height px");
    else
        return $file; 
}

Post a comment

Your email address will not be published.

10 comments

  1. Santossep

    http://zithromaxproff.com/# zithromax 500 mg
    buy zithromax online

  2. BillyBom

    nitrofurantoin online: flagyl online
    buy panmycin

  3. MichaelDiund

    indian online pharmacies review: trusted india online pharmacies order medications online from india

  4. MichaelDiund

    best india pharmacy: best online international pharmacies india all generic meds from india

  5. Robertcooto

    viagra pills online: https://edpillsonline24.com/# kamagra pills

  6. Michaelgox

    price of viagra: viagra without a doctor prescription canada no prescription viagra

  7. Claudaluck

    diflucan prescription cost: diflucan 150 price – diflucan online paypal

  8. Claudaluck

    clomid online no prescription: buy clomid – clomid online

  9. Claudaluck

    doxycycline: online doxycycline – doxycycline

  10. Claudaluck

    purchase clomiphene: buy clomid – purchase clomid

test