limit upload size to site's available limit, see #12853
git-svn-id: http://svn.automattic.com/wordpress/trunk@14420 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
02c300164a
commit
bc0ae7852f
|
@ -399,11 +399,28 @@ function is_upload_space_available() {
|
|||
if ( get_site_option( 'upload_space_check_disabled' ) )
|
||||
return true;
|
||||
|
||||
$space_allowed = get_space_allowed();
|
||||
if ( !( $space_allowed = get_upload_space_available() ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function upload_size_limit_filter( $size ) {
|
||||
return min( $size, get_upload_space_available() );
|
||||
}
|
||||
/**
|
||||
* Determines if there is any upload space left in the current blog's quota.
|
||||
*
|
||||
* @return int of upload space available in bytes
|
||||
*/
|
||||
function get_upload_space_available() {
|
||||
$space_allowed = get_space_allowed() * 1024 * 1024;
|
||||
if ( get_site_option( 'upload_space_check_disabled' ) )
|
||||
return $space_allowed;
|
||||
|
||||
$dir_name = trailingslashit( BLOGUPLOADDIR );
|
||||
if ( !( is_dir( $dir_name) && is_readable( $dir_name ) ) )
|
||||
return true;
|
||||
return $space_allowed;
|
||||
|
||||
$dir = dir( $dir_name );
|
||||
$size = 0;
|
||||
|
@ -418,12 +435,11 @@ function is_upload_space_available() {
|
|||
}
|
||||
}
|
||||
$dir->close();
|
||||
$size = $size / 1024 / 1024;
|
||||
|
||||
if ( ( $space_allowed - $size ) <= 0 )
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
return true;
|
||||
return $space_allowed - $size;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,6 +45,7 @@ add_filter( 'wp_upload_bits', 'upload_is_file_too_big' );
|
|||
add_filter( 'import_upload_size_limit', 'fix_import_form_size' );
|
||||
add_filter( 'upload_mimes', 'check_upload_mimes' );
|
||||
add_action( 'admin_notices', 'ms_deprecated_blogs_file' );
|
||||
add_action( 'upload_size_limit', 'upload_size_limit_filter' );
|
||||
|
||||
// Mail
|
||||
add_filter( 'wp_mail_from', 'wordpressmu_wp_mail_from' );
|
||||
|
|
Loading…
Reference in New Issue