WordPress.org

Make WordPress Core

Changeset 14420


Ignore:
Timestamp:
05/03/2010 10:40:02 PM (8 years ago)
Author:
wpmuguru
Message:

limit upload size to site's available limit, see #12853

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ms.php

    r14404 r14420  
    400400        return true;
    401401
    402     $space_allowed = get_space_allowed();
     402    if ( !( $space_allowed = get_upload_space_available() ) )
     403        return false;
     404
     405    return true;
     406}
     407
     408function upload_size_limit_filter( $size ) {
     409    return min( $size, get_upload_space_available() );
     410}
     411/**
     412 * Determines if there is any upload space left in the current blog's quota.
     413 *
     414 * @return int of upload space available in bytes
     415 */
     416function get_upload_space_available() {
     417    $space_allowed = get_space_allowed() * 1024 * 1024;
     418    if ( get_site_option( 'upload_space_check_disabled' ) )
     419        return $space_allowed;
    403420
    404421    $dir_name = trailingslashit( BLOGUPLOADDIR );
    405422    if ( !( is_dir( $dir_name) && is_readable( $dir_name ) ) )
    406         return true;
     423        return $space_allowed;
    407424
    408425    $dir = dir( $dir_name );
     
    419436    }
    420437    $dir->close();
    421     $size = $size / 1024 / 1024;
    422438
    423439    if ( ( $space_allowed - $size ) <= 0 )
    424         return false;
    425 
    426     return true;
     440        return 0;
     441
     442    return $space_allowed - $size;
    427443}
    428444
  • trunk/wp-includes/ms-default-filters.php

    r13998 r14420  
    4646add_filter( 'upload_mimes', 'check_upload_mimes' );
    4747add_action( 'admin_notices', 'ms_deprecated_blogs_file' );
     48add_action( 'upload_size_limit', 'upload_size_limit_filter' );
    4849
    4950// Mail
Note: See TracChangeset for help on using the changeset viewer.