apply_filters( 'upload_size_limit', int $size, int $u_bytes, int $p_bytes )

Filters the maximum upload size allowed in php.ini.


Description Description


Parameters Parameters

$size

(int) Max upload size limit in bytes.

$u_bytes

(int) Maximum upload filesize in bytes.

$p_bytes

(int) Maximum size of POST data in bytes.


Top ↑

Source Source

File: wp-includes/media.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
2.5.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Drew Jaynes
    /**
     * 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.