bp_core_upload_max_size()

Return the file upload max size in bytes.

Description

Return

(mixed|void)

Source

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

5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
function bp_core_upload_max_size() {
 
    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;
        }
    }
 
    /**
     * Filters file upload max limit.
     *
     * @param mixed $max_size file upload max limit.
     *
     * @since BuddyBoss 1.4.8
     */
    return apply_filters( 'bp_core_upload_max_size', $max_size );
 
}

Changelog

Changelog
Version Description
BuddyBoss 1.4.8 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.