<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[22821] trunk/wp-includes: Media: Make friends with media_upload_form.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/22821">22821</a></dd>
<dt>Author</dt> <dd>koopersmith</dd>
<dt>Date</dt> <dd>2012-11-22 11:46:03 +0000 (Thu, 22 Nov 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>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 <a href="http://core.trac.wordpress.org/ticket/22243">#22243</a>, see <a href="http://core.trac.wordpress.org/ticket/22186">#22186</a>, <a href="http://core.trac.wordpress.org/ticket/21390">#21390</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludescssmediaviewscss">trunk/wp-includes/css/media-views.css</a></li>
<li><a href="#trunkwpincludesjsmediaviewsjs">trunk/wp-includes/js/media-views.js</a></li>
<li><a href="#trunkwpincludesmediaphp">trunk/wp-includes/media.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludescssmediaviewscss"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/css/media-views.css (22820 => 22821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/css/media-views.css        2012-11-22 10:58:36 UTC (rev 22820)
+++ trunk/wp-includes/css/media-views.css        2012-11-22 11:46:03 UTC (rev 22821)
</span><span class="lines">@@ -883,10 +883,6 @@
</span><span class="cx">         display: block;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-.upload-flash-bypass {
-        font-size: 12px;
-}
-
</del><span class="cx"> .region-content.uploader-inline {
</span><span class="cx">         margin: 20px;
</span><span class="cx">         padding: 20px;
</span><span class="lines">@@ -905,16 +901,24 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> .uploader-inline h3 {
</span><del>-        display: none;
</del><span class="cx">         font-size: 20px;
</span><ins>+        line-height: 28px;
</ins><span class="cx">         font-weight: 200;
</span><span class="cx">         margin-bottom: 1.6em;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-.supports-drag-drop .uploader-inline h3 {
</del><ins>+.uploader-inline .drop-instructions {
+        display: none;
+}
+
+.supports-drag-drop .uploader-inline .drop-instructions {
</ins><span class="cx">         display: block;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+.uploader-inline p {
+        font-size: 12px;
+}
+
</ins><span class="cx"> .uploader-inline .media-progress-bar {
</span><span class="cx">         display: none;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpincludesjsmediaviewsjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/media-views.js (22820 => 22821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/media-views.js        2012-11-22 10:58:36 UTC (rev 22820)
+++ trunk/wp-includes/js/media-views.js        2012-11-22 11:46:03 UTC (rev 22821)
</span><span class="lines">@@ -1100,6 +1100,11 @@
</span><span class="cx">                                 });
</span><span class="cx">                         }
</span><span class="cx">
</span><ins>+                        // Force the uploader off if the upload limit has been exceeded or
+                        // if the browser isn't supported.
+                        if ( wp.Uploader.limitExceeded || ! wp.Uploader.browser.supported )
+                                this.options.uploader = false;
+
</ins><span class="cx">                         // Initialize window-wide uploader.
</span><span class="cx">                         if ( this.options.uploader ) {
</span><span class="cx">                                 this.uploader = new media.view.UploaderWindow({
</span><span class="lines">@@ -1785,51 +1790,22 @@
</span><span class="cx">                 initialize: function() {
</span><span class="cx">                         this.controller = this.options.controller;
</span><span class="cx">
</span><del>-                        if ( ! this.options.$browser )
</del><ins>+                        if ( ! this.options.$browser && this.controller.uploader )
</ins><span class="cx">                                 this.options.$browser = this.controller.uploader.$browser;
</span><del>-
-                        // Track uploading attachments.
-                        wp.Uploader.queue.on( 'add remove reset change:percent', this.renderUploadProgress, this );
</del><span class="cx">                 },
</span><span class="cx">
</span><del>-                dispose: function() {
-                        wp.Uploader.queue.off( null, null, this );
-                        media.View.prototype.dispose.apply( this, arguments );
-                        return this;
-                },
-
-                render: function() {
</del><ins>+                ready: function() {
</ins><span class="cx">                         var $browser = this.options.$browser,
</span><span class="cx">                                 $placeholder;
</span><span class="cx">
</span><del>-                        this.renderUploadProgress();
-                        this.$el.html( this.template( this.options ) );
</del><ins>+                        if ( this.controller.uploader ) {
+                                $placeholder = this.$('.browser');
+                                $browser.detach().text( $placeholder.text() );
+                                $browser[0].className = $placeholder[0].className;
+                                $placeholder.replaceWith( $browser.show() );
+                        }
</ins><span class="cx">
</span><del>-                        $placeholder = this.$('.browser');
-                        $browser.detach().text( $placeholder.text() );
-                        $browser[0].className = $placeholder[0].className;
-                        $placeholder.replaceWith( $browser.show() );
-
-                        this.$bar = this.$('.media-progress-bar div');
-
-                        this.views.render();
</del><span class="cx">                         return this;
</span><del>-                },
-
-                renderUploadProgress: function() {
-                        var queue = wp.Uploader.queue;
-
-                        this.$el.toggleClass( 'uploading', !! queue.length );
-
-                        if ( ! this.$bar || ! queue.length )
-                                return;
-
-                        this.$bar.width( ( queue.reduce( function( memo, attachment ) {
-                                if ( attachment.get('uploading') )
-                                        return memo + ( attachment.get('percent') || 0 );
-                                else
-                                        return memo + 100;
-                        }, 0 ) / queue.length ) + '%' );
</del><span class="cx">                 }
</span><span class="cx">         });
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/media.php (22820 => 22821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/media.php        2012-11-22 10:58:36 UTC (rev 22820)
+++ trunk/wp-includes/media.php        2012-11-22 11:46:03 UTC (rev 22821)
</span><span class="lines">@@ -1271,6 +1271,7 @@
</span><span class="cx">                         'mobile' => wp_is_mobile(),
</span><span class="cx">                         'supported' => _device_can_upload(),
</span><span class="cx">                 ),
</span><ins>+                'limitExceeded' => is_multisite() && ! is_upload_space_available()
</ins><span class="cx">         );
</span><span class="cx">
</span><span class="cx">         $script = 'var _wpPluploadSettings = ' . json_encode( $settings ) . ';';
</span><span class="lines">@@ -1484,8 +1485,15 @@
</span><span class="cx">
</span><span class="cx">         <script type="text/html" id="tmpl-uploader-inline">
</span><span class="cx">                 <div class="uploader-inline-content">
</span><ins>+                <?php if ( ! _device_can_upload() ) : ?>
+                        <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>
+                <?php elseif ( is_multisite() && ! is_upload_space_available() ) : ?>
+                        <h3><?php _e( 'Upload Limit Exceeded' ); ?></h3>
+                        <?php do_action( 'upload_ui_over_quota' ); ?>
+
+                <?php else : ?>
</ins><span class="cx">                         <div class="upload-ui">
</span><del>-                                <h3><?php _e( 'Drop files anywhere to upload' ); ?></h3>
</del><ins>+                                <h3 class="drop-instructions"><?php _e( 'Drop files anywhere to upload' ); ?></h3>
</ins><span class="cx">                                 <a href="#" class="browser button button-hero"><?php _e( 'Select Files' ); ?></a>
</span><span class="cx">                         </div>
</span><span class="cx">
</span><span class="lines">@@ -1493,8 +1501,35 @@
</span><span class="cx">                                 <?php do_action( 'pre-upload-ui' ); ?>
</span><span class="cx">                                 <?php do_action( 'pre-plupload-upload-ui' ); ?>
</span><span class="cx">                                 <?php do_action( 'post-plupload-upload-ui' ); ?>
</span><ins>+
+                                <?php
+                                $upload_size_unit = $max_upload_size = wp_max_upload_size();
+                                $byte_sizes = array( 'KB', 'MB', 'GB' );
+
+                                for ( $u = -1; $upload_size_unit > 1024 && $u < count( $byte_sizes ) - 1; $u++ ) {
+                                        $upload_size_unit /= 1024;
+                                }
+
+                                if ( $u < 0 ) {
+                                        $upload_size_unit = 0;
+                                        $u = 0;
+                                } else {
+                                        $upload_size_unit = (int) $upload_size_unit;
+                                }
+
+                                ?>
+
+                                <p class="max-upload-size"><?php
+                                        printf( __( 'Maximum upload file size: %d%s.' ), esc_html($upload_size_unit), esc_html($byte_sizes[$u]) );
+                                ?></p>
+
+                                <?php if ( ( $GLOBALS['is_IE'] || $GLOBALS['is_opera']) && $max_upload_size > 100 * 1024 * 1024 ) : ?>
+                                        <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>
+                                <?php endif; ?>
+
</ins><span class="cx">                                 <?php do_action( 'post-upload-ui' ); ?>
</span><span class="cx">                         </div>
</span><ins>+                <?php endif; ?>
</ins><span class="cx">                 </div>
</span><span class="cx">         </script>
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>