I want to prevent vendors on my WordPress website to upload low resolution images. I want to exclude certain pages as I want them to be able to let them upload their logo and banner. I already received following code snippet which works on all pages:
function resize_image_resolution($file) {
if(is_user_wcmp_vendor(get_current_user_id())){
$image = getimagesize($file['tmp_name']);
$minimum = array(
'width' => '1080', //set your minimum
'height' => '1080'
);
$maximum = array(
'width' => '12000', //set your maximum
'height' => '12000'
);
$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;
} else {
return $file;
}
}
add_filter('wp_handle_upload_prefilter', 'resize_image_resolution');
I also received following hook to exclude a certain page but unfortunately I'm not able to combine them. Anyone that can help me out?
do_action('wcmp_before_shop_front');