apply_filters( ‘upload_size_limit’, int $size, int $u_bytes, int $p_bytes )

Filters the maximum upload size allowed in php.ini.

Parameters

$sizeint
Max upload size limit in bytes.
$u_bytesint
Maximum upload filesize in bytes.
$p_bytesint
Maximum size of POST data in bytes.

Source

return apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes );

Changelog

VersionDescription
2.5.0Introduced.

User Contributed Notes

  1. Skip to note 3 content
    /**
     * Filter the upload size limit for non-administrators.
     *
     * @param string $size Upload size limit (in bytes).
     * @return int (maybe) Filtered size limit.
     */
    function filter_site_upload_size_limit( $size ) {
    	// Set the upload size limit to 10 MB for users lacking the 'manage_options' capability.
    	if ( ! current_user_can( 'manage_options' ) ) {
    		// 10 MB.
    		$size = 1024 * 10000;
    	}
    	return $size;
    }
    add_filter( 'upload_size_limit', 'filter_site_upload_size_limit', 20 );

You must log in before being able to contribute a note or feedback.