WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/22/2012 11:46:03 AM (9 years ago)
Author:
koopersmith
Message:

Media: Make friends with media_upload_form. Adds notices for browser incompatibility, upload limits, maximum file size, and large file issues to the uploader. fixes #22243, see #22186, #21390.

File:
1 edited

Legend:

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

    r22819 r22821  
    12721272            'supported' => _device_can_upload(),
    12731273        ),
     1274        'limitExceeded' => is_multisite() && ! is_upload_space_available()
    12741275    );
    12751276
     
    14851486    <script type="text/html" id="tmpl-uploader-inline">
    14861487        <div class="uploader-inline-content">
     1488        <?php if ( ! _device_can_upload() ) : ?>
     1489            <h3><?php _e('The web browser on your device cannot be used to upload files. You may be able to use the <a href="http://wordpress.org/extend/mobile/">native app for your device</a> instead.'); ?></h3>
     1490        <?php elseif ( is_multisite() && ! is_upload_space_available() ) : ?>
     1491            <h3><?php _e( 'Upload Limit Exceeded' ); ?></h3>
     1492            <?php do_action( 'upload_ui_over_quota' ); ?>
     1493
     1494        <?php else : ?>
    14871495            <div class="upload-ui">
    1488                 <h3><?php _e( 'Drop files anywhere to upload' ); ?></h3>
     1496                <h3 class="drop-instructions"><?php _e( 'Drop files anywhere to upload' ); ?></h3>
    14891497                <a href="#" class="browser button button-hero"><?php _e( 'Select Files' ); ?></a>
    14901498            </div>
     
    14941502                <?php do_action( 'pre-plupload-upload-ui' ); ?>
    14951503                <?php do_action( 'post-plupload-upload-ui' ); ?>
     1504
     1505                <?php
     1506                $upload_size_unit = $max_upload_size = wp_max_upload_size();
     1507                $byte_sizes = array( 'KB', 'MB', 'GB' );
     1508
     1509                for ( $u = -1; $upload_size_unit > 1024 && $u < count( $byte_sizes ) - 1; $u++ ) {
     1510                    $upload_size_unit /= 1024;
     1511                }
     1512
     1513                if ( $u < 0 ) {
     1514                    $upload_size_unit = 0;
     1515                    $u = 0;
     1516                } else {
     1517                    $upload_size_unit = (int) $upload_size_unit;
     1518                }
     1519
     1520                ?>
     1521
     1522                <p class="max-upload-size"><?php
     1523                    printf( __( 'Maximum upload file size: %d%s.' ), esc_html($upload_size_unit), esc_html($byte_sizes[$u]) );
     1524                ?></p>
     1525
     1526                <?php if ( ( $GLOBALS['is_IE'] || $GLOBALS['is_opera']) && $max_upload_size > 100 * 1024 * 1024 ) : ?>
     1527                    <p class="big-file-warning"><?php _e('Your browser has some limitations uploading large files with the multi-file uploader. Please use the browser uploader for files over 100MB.'); ?></p>
     1528                <?php endif; ?>
     1529
    14961530                <?php do_action( 'post-upload-ui' ); ?>
    14971531            </div>
     1532        <?php endif; ?>
    14981533        </div>
    14991534    </script>
Note: See TracChangeset for help on using the changeset viewer.