Claim your freedom to choose the perfect partner for your multi-vendor journey.

FREEDOM25

Celebrate the festive season by giving your marketplace a powerful lift!

FESTIVE20

5.0.0
Something big is coming for marketplace admins… MultiVendorX 5.0 is almost here. Are you ready?
Be the first to explore all the game-changing features!
Power your marketplace dreams with unbeatable Black Friday deals!

MVXBLACK30

Supercharge your marketplace vision with unstoppable Cyber Monday deals!

MVXCYBER30

Holiday cheer, bigger savings
Take 25% off-because your marketplace deserves a gift too.

happyholiday

View Categories

Product Image size restriction

When someone uploading an images how can we manage that they are not to big, it is possible to downsize those to lets say 500×500 automatically?

>> There is no automated solution for this. However using the below code you can add restriction on this :

function resize_resolution($file) {
$image = getimagesize($file['tmp_name']);
    $minimum = array(
        'width' => '400',   //set your minimum
        'height' => '400'
    );
    $maximum = array(
        'width' => '2000',  //set your maximum
        'height' => '2000'
    );
    $image_width = $image[0];
    $image_height = $image[1];

    $too_small = "Image dimensions are too small.";
    $too_large = "Image dimensions are too large.";

    if ( $image_width < $minimum['width'] || $image_height < $minimum['height'] ) {
        $file['error'] = $too_small; 
        return $file;
    }
    elseif ( $image_width > $maximum['width'] || $image_height > $maximum['height'] ) {
        $file['error'] = $too_large; 
        return $file;
    }
    else
        return $file;
}
add_filter('wp_handle_upload_prefilter', 'resize_resolution');

Leave a Reply

Shopping Cart
Scroll to Top