Banner Logo

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

Maximum Size of image uploading

add restriction for vendor upload
function limit_upload_size_limit_for_non_admin( $limit ) {
if(is_user_mvx_vendor(get_current_user_id())){
    $limit = '258000'; // 1kb in bytes
  }
  return $limit;
}
 
add_filter( 'upload_size_limit', 'limit_upload_size_limit_for_non_admin' );
 
 
function apply_wp_handle_upload_prefilter( $file ) {
if(is_user_mvx_vendor(get_current_user_id())){
    $limit = 258000; // 1kb in bytes
    if ( $file['size'] > $limit ) {
      $file['error'] = sprintf( __( 'ERROR: File size limit is %d KB.' ), $limit);
    }
  }
  return $file;
}
 
add_filter( 'wp_handle_upload_prefilter', 'apply_wp_handle_upload_prefilter' );

Leave a Reply