WCMp Core
-
AuthorPosts
-
-
September 5, 2021 at 7:40 PM #127184erezParticipant
Hi Friends .
I would love to know how to limit vendor upload size IMAGE to maximum 500KB .
It is important that it only affects vendor And not admin .Thanks so much for the help and very much appreciate it 🙂
-
September 6, 2021 at 1:10 PM #127198NerdySupportExpert MoumitaKeymaster
Hi @verez, nice to hear from you again.
This thread will help you out better on this : https://multivendorx.com/support-forum/topic/enforce-minimum-and-maximum-image-resolutions-on-vendor-upload/#post-70744
-
September 8, 2021 at 8:07 PM #127334erezParticipant
HI Thanks
It works, but it also affects the cover And the logo image on vendor SHOP .
What line of code I need to add So that it does not affect it ?Will this code work: do_action(‘wcmp_before_shop_front’);
If so where do I add it in all these lines:
/** Upload image restriction ****/
function resize_image_resolution($file) {
if(is_user_wcmp_vendor(get_current_user_id())){
$image = getimagesize($file[‘tmp_name’]);
$minimum = array(
‘width’ => ‘400’, //set your minimum
‘height’ => ‘400’
);
$maximum = array(
‘width’ => ‘1000’, //set your maximum
‘height’ => ‘1000’
);
$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’); -
September 9, 2021 at 1:30 PM #127352MVX Support NinjaKeymaster
Hi,
As per your requirement you have to add checking using the page id to restricted the function.
Let me know which page you want to restrict from this function.Regards,
-
September 9, 2021 at 7:01 PM #127382erezParticipantThis reply has been marked as private.
-
September 9, 2021 at 7:06 PM #127384MVX Support NinjaKeymasterThis reply has been marked as private.
-
September 9, 2021 at 11:32 PM #127402erezParticipantThis reply has been marked as private.
-
September 10, 2021 at 6:33 PM #127430MVX Support NinjaKeymaster
Hi,
You can check the page using below codeglobal $WCMp; if( $WCMp->endpoints->get_current_endpoint() != 'storefront' ){ //your code }
CopyRegards,
-
September 10, 2021 at 10:59 PM #127440erezParticipant
HI
But where do I add the code Within the other lines of code?
Can you add it to the other code That I’ll just have to copy
When all the codes are already connected together . -
September 11, 2021 at 6:51 PM #127452MVX Support NinjaKeymasterThis reply has been marked as private.
-
September 11, 2021 at 8:02 PM #127455NerdySupportExpert MoumitaKeymaster
@erez, the code we shared earlier works for all image uploads.
Now as you need this for specific pages, that case this requires new custom code.
I have asked the team to provide this. But it will take some time.
-
-
AuthorPosts
The topic ‘limit vendor upload size IMAGE’ is closed to new replies.