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-includes/media-template.php

    r28184 r28343  
    187187                }
    188188
    189                 $upload_size_unit = $max_upload_size = wp_max_upload_size();
    190                 $byte_sizes = array( 'KB', 'MB', 'GB' );
    191 
    192                 for ( $u = -1; $upload_size_unit > 1024 && $u < count( $byte_sizes ) - 1; $u++ ) {
    193                     $upload_size_unit /= 1024;
     189                $max_upload_size = wp_max_upload_size();
     190                if ( ! $max_upload_size ) {
     191                    $max_upload_size = 0;
    194192                }
    195 
    196                 if ( $u < 0 ) {
    197                     $upload_size_unit = 0;
    198                     $u = 0;
    199                 } else {
    200                     $upload_size_unit = (int) $upload_size_unit;
    201                 }
    202 
    203193                ?>
    204194
    205195                <p class="max-upload-size"><?php
    206                     printf( __( 'Maximum upload file size: %d%s.' ), esc_html($upload_size_unit), esc_html($byte_sizes[$u]) );
     196                    printf( __( 'Maximum upload file size: %s.' ), esc_html( size_format( $max_upload_size ) ) );
    207197                ?></p>
    208198
Note: See TracChangeset for help on using the changeset viewer.