bp_document_file_upload_max_size()

Get file document upload max size

Description

Parameters

$post_string

(Required)

Return

(string)

Source

File: bp-document/bp-document-functions.php

262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
function bp_document_file_upload_max_size( $post_string = false, $type = 'bytes' ) {
    static $max_size = - 1;
 
    if ( $max_size < 0 ) {
        // Start with post_max_size.
        $size = @ini_get( 'post_max_size' );
        $unit = preg_replace( '/[^bkmgtpezy]/i', '', $size ); // Remove the non-unit characters from the size.
        $size = preg_replace( '/[^0-9\.]/', '', $size );      // Remove the non-numeric characters from the size.
        if ( $unit ) {
            $post_max_size = round( $size * pow( 1024, stripos( 'bkmgtpezy', $unit[0] ) ) );
        } else {
            $post_max_size = round( $size );
        }
 
        if ( $post_max_size > 0 ) {
            $max_size = $post_max_size;
        }
 
        // If upload_max_size is less, then reduce. Except if upload_max_size is
        // zero, which indicates no limit.
        $size = @ini_get( 'upload_max_filesize' );
        $unit = preg_replace( '/[^bkmgtpezy]/i', '', $size ); // Remove the non-unit characters from the size.
        $size = preg_replace( '/[^0-9\.]/', '', $size );      // Remove the non-numeric characters from the size.
        if ( $unit ) {
            $upload_max = round( $size * pow( 1024, stripos( 'bkmgtpezy', $unit[0] ) ) );
        } else {
            $upload_max = round( $size );
        }
        if ( $upload_max > 0 && $upload_max < $max_size ) {
            $max_size = $upload_max;
        }
    }
 
    return apply_filters( 'bp_document_file_upload_max_size', bp_document_format_size_units( $max_size, $post_string, $type ) );
}

Changelog

Changelog
Version Description
BuddyBoss 1.4.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.