Banner Logo

Be a part of the family: Connect, Receive Support,
Contribute, and Reap Abundant Rewards!

limit vendor upload size IMAGE

WCMp Core

Resolved
Viewing 10 reply threads
  • Author
    Posts
    • #127184
      erez
      Participant

      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 🙂

    • #127198

      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

    • #127334
      erez
      Participant

      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’);

    • #127352

      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,

    • #127382
      erez
      Participant
      This reply has been marked as private.
    • #127384
      This reply has been marked as private.
    • #127402
      erez
      Participant
      This reply has been marked as private.
    • #127430

      Hi,
      You can check the page using below code

      global $WCMp;
          if( $WCMp->endpoints->get_current_endpoint() != 'storefront' ){
              //your code
          }
      Copy

      Regards,

    • #127440
      erez
      Participant

      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 .

    • #127452
      This reply has been marked as private.
    • #127455

      @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.

Viewing 10 reply threads

The topic ‘limit vendor upload size IMAGE’ is closed to new replies.