Make WordPress Core


Ignore:
Timestamp:
05/07/2014 06:24:47 PM (11 years ago)
Author:
wonderboymusic
Message:

Leverage size_format() when displaying max_upload_size:

  • In media_upload_form()
  • The uploader-inline Underscore template in the media modal.

Replaces 2 buggy inline implementations that could display size units off by one, or size values off by one.

Fixes #25643.

File:
1 edited

Legend:

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

    r28297 r28343  
    16911691    $_tab = isset($tab) ? $tab : '';
    16921692
    1693     $upload_size_unit = $max_upload_size = wp_max_upload_size();
    1694     $sizes = array( 'KB', 'MB', 'GB' );
    1695 
    1696     for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ ) {
    1697         $upload_size_unit /= 1024;
    1698     }
    1699 
    1700     if ( $u < 0 ) {
    1701         $upload_size_unit = 0;
    1702         $u = 0;
    1703     } else {
    1704         $upload_size_unit = (int) $upload_size_unit;
     1693    $max_upload_size = wp_max_upload_size();
     1694    if ( ! $max_upload_size ) {
     1695        $max_upload_size = 0;
    17051696    }
    17061697?>
     
    17371728
    17381729$post_params = array(
    1739         "post_id" => $post_id,
    1740         "_wpnonce" => wp_create_nonce('media-form'),
    1741         "type" => $_type,
    1742         "tab" => $_tab,
    1743         "short" => "1",
     1730    "post_id" => $post_id,
     1731    "_wpnonce" => wp_create_nonce('media-form'),
     1732    "type" => $_type,
     1733    "tab" => $_tab,
     1734    "short" => "1",
    17441735);
    17451736
     
    18511842</div>
    18521843
    1853 <span class="max-upload-size"><?php printf( __( 'Maximum upload file size: %d%s.' ), esc_html($upload_size_unit), esc_html($sizes[$u]) ); ?></span>
     1844<span class="max-upload-size"><?php printf( __( 'Maximum upload file size: %s.' ), esc_html( size_format( $max_upload_size ) ) ); ?></span>
    18541845<?php
    18551846
Note: See TracChangeset for help on using the changeset viewer.