]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/media-template.php
WordPress 4.1.1-scripts
[autoinstalls/wordpress.git] / wp-includes / media-template.php
index 25354618d90e279b4512d93fc8c2b9d60cc5403b..758c7f5c528b977561c38122a1be6d5df7efae64 100644 (file)
@@ -50,7 +50,8 @@ function wp_underscore_audio_template() {
 function wp_underscore_video_template() {
        $video_types = wp_get_video_extensions();
 ?>
-<#  var w, h, settings = wp.media.view.settings,
+<#  var w_rule = h_rule = '',
+               w, h, settings = wp.media.view.settings,
                isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/);
 
        if ( settings.contentWidth && data.model.width >= settings.contentWidth ) {
@@ -60,16 +61,23 @@ function wp_underscore_video_template() {
        }
 
        if ( w !== data.model.width ) {
-               h = Math.ceil( ( h * w ) / data.model.width );
+               h = Math.ceil( ( data.model.height * w ) / data.model.width );
        } else {
                h = data.model.height;
        }
+
+       if ( w ) {
+               w_rule = 'width: ' + w + 'px; ';
+       }
+       if ( h ) {
+               h_rule = 'height: ' + h + 'px;';
+       }
 #>
-<div style="max-width: 100%; width: {{ w }}px">
+<div style="{{ w_rule }}{{ h_rule }}" class="wp-video">
 <video controls
        class="wp-video-shortcode{{ isYouTube ? ' youtube-video' : '' }}"
-       width="{{ w }}"
-       height="{{ h }}"
+       <# if ( w ) { #>width="{{ w }}"<# } #>
+       <# if ( h ) { #>height="{{ h }}"<# } #>
        <?php
        $props = array( 'poster' => '', 'preload' => 'metadata' );
        foreach ( $props as $key => $value ):
@@ -119,6 +127,16 @@ function wp_print_media_templates() {
        if ( $is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false )
                $class .= ' ie7';
        ?>
+       <!--[if lte IE 8]>
+       <style>
+               .attachment:focus {
+                       outline: #1e8cbe solid;
+               }
+               .selected.attachment {
+                       outline: #1e8cbe solid;
+               }
+       </style>
+       <![endif]-->
        <script type="text/html" id="tmpl-media-frame">
                <div class="media-frame-menu"></div>
                <div class="media-frame-title"></div>
@@ -130,7 +148,7 @@ function wp_print_media_templates() {
 
        <script type="text/html" id="tmpl-media-modal">
                <div class="<?php echo $class; ?>">
-                       <a class="media-modal-close" href="#" title="<?php esc_attr_e('Close'); ?>"><span class="media-modal-icon"></span></a>
+                       <a class="media-modal-close" href="#"><span class="media-modal-icon"><span class="screen-reader-text"><?php _e( 'Close media panel' ); ?></span></span></a>
                        <div class="media-modal-content"></div>
                </div>
                <div class="media-modal-backdrop"></div>
@@ -150,12 +168,15 @@ function wp_print_media_templates() {
 
        <script type="text/html" id="tmpl-uploader-inline">
                <# var messageClass = data.message ? 'has-upload-message' : 'no-upload-message'; #>
+               <# if ( data.canClose ) { #>
+               <button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close uploader' ); ?></span></button>
+               <# } #>
                <div class="uploader-inline-content {{ messageClass }}">
                <# if ( data.message ) { #>
                        <h3 class="upload-message">{{ data.message }}</h3>
                <# } #>
                <?php if ( ! _device_can_upload() ) : ?>
-                       <h3 class="upload-instructions"><?php printf( __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.'), 'https://wordpress.org/mobile/' ); ?></h3>
+                       <h3 class="upload-instructions"><?php printf( __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.'), 'https://apps.wordpress.org/' ); ?></h3>
                <?php elseif ( is_multisite() && ! is_upload_space_available() ) : ?>
                        <h3 class="upload-instructions"><?php _e( 'Upload Limit Exceeded' ); ?></h3>
                        <?php
@@ -165,6 +186,7 @@ function wp_print_media_templates() {
                <?php else : ?>
                        <div class="upload-ui">
                                <h3 class="upload-instructions drop-instructions"><?php _e( 'Drop files anywhere to upload' ); ?></h3>
+                               <p class="upload-instructions drop-instructions"><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p>
                                <a href="#" class="browser button button-hero"><?php _e( 'Select Files' ); ?></a>
                        </div>
 
@@ -186,24 +208,14 @@ function wp_print_media_templates() {
                                        do_action( 'post-plupload-upload-ui' );
                                }
 
-                               $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;
+                               $max_upload_size = wp_max_upload_size();
+                               if ( ! $max_upload_size ) {
+                                       $max_upload_size = 0;
                                }
-
                                ?>
 
                                <p class="max-upload-size"><?php
-                                       printf( __( 'Maximum upload file size: %d%s.' ), esc_html($upload_size_unit), esc_html($byte_sizes[$u]) );
+                                       printf( __( 'Maximum upload file size: %s.' ), esc_html( size_format( $max_upload_size ) ) );
                                ?></p>
 
                                <# if ( data.suggestedWidth && data.suggestedHeight ) { #>
@@ -220,6 +232,15 @@ function wp_print_media_templates() {
                </div>
        </script>
 
+       <script type="text/html" id="tmpl-media-library-view-switcher">
+               <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-list">
+                       <span class="screen-reader-text"><?php _e( 'List View' ); ?></span>
+               </a>
+               <a href="<?php echo esc_url( add_query_arg( 'mode', 'grid', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-grid current">
+                       <span class="screen-reader-text"><?php _e( 'Grid View' ); ?></span>
+               </a>
+       </script>
+
        <script type="text/html" id="tmpl-uploader-status">
                <h3><?php _e( 'Uploading' ); ?></h3>
                <a class="upload-dismiss-errors" href="#"><?php _e('Dismiss Errors'); ?></a>
@@ -241,35 +262,205 @@ function wp_print_media_templates() {
                <span class="upload-error-message">{{ data.message }}</span>
        </script>
 
-       <script type="text/html" id="tmpl-attachment">
-               <div class="attachment-preview type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">
-                       <# if ( data.uploading ) { #>
-                               <div class="media-progress-bar"><div></div></div>
-                       <# } else if ( 'image' === data.type ) { #>
-                               <div class="thumbnail">
-                                       <div class="centered">
-                                               <img src="{{ data.size.url }}" draggable="false" />
-                                       </div>
+       <script type="text/html" id="tmpl-edit-attachment-frame">
+               <div class="edit-media-header">
+                       <button class="left dashicons <# if ( ! data.hasPrevious ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit previous media item' ); ?></span></button>
+                       <button class="right dashicons <# if ( ! data.hasNext ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit next media item' ); ?></span></button>
+               </div>
+               <div class="media-frame-title"></div>
+               <div class="media-frame-content"></div>
+       </script>
+
+       <script type="text/html" id="tmpl-attachment-details-two-column">
+               <div class="attachment-media-view {{ data.orientation }}">
+                       <div class="thumbnail thumbnail-{{ data.type }}">
+                               <# if ( data.uploading ) { #>
+                                       <div class="media-progress-bar"><div></div></div>
+                               <# } else if ( 'image' === data.type && data.sizes && data.sizes.large ) { #>
+                                       <img class="details-image" src="{{ data.sizes.large.url }}" draggable="false" />
+                               <# } else if ( 'image' === data.type && data.sizes && data.sizes.full ) { #>
+                                       <img class="details-image" src="{{ data.sizes.full.url }}" draggable="false" />
+                               <# } else if ( -1 === jQuery.inArray( data.type, [ 'audio', 'video' ] ) ) { #>
+                                       <img class="details-image" src="{{ data.icon }}" class="icon" draggable="false" />
+                               <# } #>
+
+                               <# if ( 'audio' === data.type ) { #>
+                               <div class="wp-media-wrapper">
+                                       <audio style="visibility: hidden" controls class="wp-audio-shortcode" width="100%" preload="none">
+                                               <source type="{{ data.mime }}" src="{{ data.url }}"/>
+                                       </audio>
                                </div>
-                       <# } else { #>
-                               <img src="{{ data.icon }}" class="icon" draggable="false" />
-                               <div class="filename">
-                                       <div>{{ data.filename }}</div>
+                               <# } else if ( 'video' === data.type ) {
+                                       var w_rule = h_rule = '';
+                                       if ( data.width ) {
+                                               w_rule = 'width: ' + data.width + 'px;';
+                                       } else if ( wp.media.view.settings.contentWidth ) {
+                                               w_rule = 'width: ' + wp.media.view.settings.contentWidth + 'px;';
+                                       }
+                                       if ( data.height ) {
+                                               h_rule = 'height: ' + data.height + 'px;';
+                                       }
+                               #>
+                               <div style="{{ w_rule }}{{ h_rule }}" class="wp-media-wrapper wp-video">
+                                       <video controls="controls" class="wp-video-shortcode" preload="metadata"
+                                               <# if ( data.width ) { #>width="{{ data.width }}"<# } #>
+                                               <# if ( data.height ) { #>height="{{ data.height }}"<# } #>
+                                               <# if ( data.image && data.image.src !== data.icon ) { #>poster="{{ data.image.src }}"<# } #>>
+                                               <source type="{{ data.mime }}" src="{{ data.url }}"/>
+                                       </video>
                                </div>
-                       <# } #>
+                               <# } #>
+
+                               <div class="attachment-actions">
+                                       <# if ( 'image' === data.type && ! data.uploading && data.sizes && data.can.save ) { #>
+                                               <a class="button edit-attachment" href="#"><?php _e( 'Edit Image' ); ?></a>
+                                       <# } #>
+                               </div>
+                       </div>
+               </div>
+               <div class="attachment-info">
+                       <span class="settings-save-status">
+                               <span class="spinner"></span>
+                               <span class="saved"><?php esc_html_e('Saved.'); ?></span>
+                       </span>
+                       <div class="details">
+                               <div class="filename"><strong><?php _e( 'File name:' ); ?></strong> {{ data.filename }}</div>
+                               <div class="filename"><strong><?php _e( 'File type:' ); ?></strong> {{ data.mime }}</div>
+                               <div class="uploaded"><strong><?php _e( 'Uploaded on:' ); ?></strong> {{ data.dateFormatted }}</div>
+
+                               <div class="file-size"><strong><?php _e( 'File size:' ); ?></strong> {{ data.filesizeHumanReadable }}</div>
+                               <# if ( 'image' === data.type && ! data.uploading ) { #>
+                                       <# if ( data.width && data.height ) { #>
+                                               <div class="dimensions"><strong><?php _e( 'Dimensions:' ); ?></strong> {{ data.width }} &times; {{ data.height }}</div>
+                                       <# } #>
+                               <# } #>
+
+                               <# if ( data.fileLength ) { #>
+                                       <div class="file-length"><strong><?php _e( 'Length:' ); ?></strong> {{ data.fileLength }}</div>
+                               <# } #>
+
+                               <# if ( 'audio' === data.type && data.meta.bitrate ) { #>
+                                       <div class="bitrate">
+                                               <strong><?php _e( 'Bitrate:' ); ?></strong> {{ Math.round( data.meta.bitrate / 1000 ) }}kb/s
+                                               <# if ( data.meta.bitrate_mode ) { #>
+                                               {{ ' ' + data.meta.bitrate_mode.toUpperCase() }}
+                                               <# } #>
+                                       </div>
+                               <# } #>
+
+                               <div class="compat-meta">
+                                       <# if ( data.compat && data.compat.meta ) { #>
+                                               {{{ data.compat.meta }}}
+                                       <# } #>
+                               </div>
+                       </div>
+
+                       <div class="settings">
+                               <label class="setting" data-setting="url">
+                                       <span class="name"><?php _e('URL'); ?></span>
+                                       <input type="text" value="{{ data.url }}" readonly />
+                               </label>
+                               <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #>
+                               <label class="setting" data-setting="title">
+                                       <span class="name"><?php _e('Title'); ?></span>
+                                       <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} />
+                               </label>
+                               <# if ( 'audio' === data.type ) { #>
+                               <?php foreach ( array(
+                                       'artist' => __( 'Artist' ),
+                                       'album' => __( 'Album' ),
+                               ) as $key => $label ) : ?>
+                               <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>">
+                                       <span class="name"><?php echo $label ?></span>
+                                       <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" />
+                               </label>
+                               <?php endforeach; ?>
+                               <# } #>
+                               <label class="setting" data-setting="caption">
+                                       <span class="name"><?php _e( 'Caption' ); ?></span>
+                                       <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea>
+                               </label>
+                               <# if ( 'image' === data.type ) { #>
+                                       <label class="setting" data-setting="alt">
+                                               <span class="name"><?php _e( 'Alt Text' ); ?></span>
+                                               <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} />
+                                       </label>
+                               <# } #>
+                               <label class="setting" data-setting="description">
+                                       <span class="name"><?php _e('Description'); ?></span>
+                                       <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea>
+                               </label>
+                               <label class="setting">
+                                       <span class="name"><?php _e( 'Uploaded By' ); ?></span>
+                                       <span class="value">{{ data.authorName }}</span>
+                               </label>
+                               <# if ( data.uploadedToTitle ) { #>
+                                       <label class="setting">
+                                               <span class="name"><?php _e( 'Uploaded To' ); ?></span>
+                                               <# if ( data.uploadedToLink ) { #>
+                                                       <span class="value"><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a></span>
+                                               <# } else { #>
+                                                       <span class="value">{{ data.uploadedToTitle }}</span>
+                                               <# } #>
+                                       </label>
+                               <# } #>
+                               <div class="attachment-compat"></div>
+                       </div>
 
+                       <div class="actions">
+                               <a class="view-attachment" href="{{ data.link }}"><?php _e( 'View attachment page' ); ?></a>
+                               <# if ( data.can.save ) { #> |
+                                       <a href="post.php?post={{ data.id }}&action=edit"><?php _e( 'Edit more details' ); ?></a>
+                               <# } #>
+                               <# if ( ! data.uploading && data.can.remove ) { #> |
+                                       <?php if ( MEDIA_TRASH ): ?>
+                                               <# if ( 'trash' === data.status ) { #>
+                                                       <a class="untrash-attachment" href="#"><?php _e( 'Untrash' ); ?></a>
+                                               <# } else { #>
+                                                       <a class="trash-attachment" href="#"><?php _ex( 'Trash', 'verb' ); ?></a>
+                                               <# } #>
+                                       <?php else: ?>
+                                               <a class="delete-attachment" href="#"><?php _e( 'Delete Permanently' ); ?></a>
+                                       <?php endif; ?>
+                               <# } #>
+                       </div>
+
+               </div>
+       </script>
+
+       <script type="text/html" id="tmpl-attachment">
+               <div class="attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">
+                       <div class="thumbnail">
+                               <# if ( data.uploading ) { #>
+                                       <div class="media-progress-bar"><div style="width: {{ data.percent }}%"></div></div>
+                               <# } else if ( 'image' === data.type && data.sizes ) { #>
+                                       <div class="centered">
+                                               <img src="{{ data.size.url }}" draggable="false" alt="" />
+                                       </div>
+                               <# } else { #>
+                                       <div class="centered">
+                                               <# if ( data.image && data.image.src && data.image.src !== data.icon ) { #>
+                                                       <img src="{{ data.image.src }}" class="thumbnail" draggable="false" />
+                                               <# } else { #>
+                                                       <img src="{{ data.icon }}" class="icon" draggable="false" />
+                                               <# } #>
+                                       </div>
+                                       <div class="filename">
+                                               <div>{{ data.filename }}</div>
+                                       </div>
+                               <# } #>
+                       </div>
                        <# if ( data.buttons.close ) { #>
                                <a class="close media-modal-icon" href="#" title="<?php esc_attr_e('Remove'); ?>"></a>
                        <# } #>
-
-                       <# if ( data.buttons.check ) { #>
-                               <a class="check" href="#" title="<?php esc_attr_e('Deselect'); ?>"><div class="media-modal-icon"></div></a>
-                       <# } #>
                </div>
+               <# if ( data.buttons.check ) { #>
+                       <a class="check" href="#" title="<?php esc_attr_e('Deselect'); ?>" tabindex="-1"><div class="media-modal-icon"></div></a>
+               <# } #>
                <#
                var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly';
-               if ( data.describe ) { #>
-                       <# if ( 'image' === data.type ) { #>
+               if ( data.describe ) {
+                       if ( 'image' === data.type ) { #>
                                <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption"
                                        placeholder="<?php esc_attr_e('Caption this image&hellip;'); ?>" {{ maybeReadOnly }} />
                        <# } else { #>
@@ -281,8 +472,8 @@ function wp_print_media_templates() {
                                        <# } else { #>
                                                placeholder="<?php esc_attr_e('Describe this media file&hellip;'); ?>"
                                        <# } #> {{ maybeReadOnly }} />
-                       <# } #>
-               <# } #>
+                       <# }
+               } #>
        </script>
 
        <script type="text/html" id="tmpl-attachment-details">
@@ -295,10 +486,10 @@ function wp_print_media_templates() {
                        </span>
                </h3>
                <div class="attachment-info">
-                       <div class="thumbnail">
+                       <div class="thumbnail thumbnail-{{ data.type }}">
                                <# if ( data.uploading ) { #>
                                        <div class="media-progress-bar"><div></div></div>
-                               <# } else if ( 'image' === data.type ) { #>
+                               <# } else if ( 'image' === data.type && data.sizes ) { #>
                                        <img src="{{ data.size.url }}" draggable="false" />
                                <# } else { #>
                                        <img src="{{ data.icon }}" class="icon" draggable="false" />
@@ -308,12 +499,13 @@ function wp_print_media_templates() {
                                <div class="filename">{{ data.filename }}</div>
                                <div class="uploaded">{{ data.dateFormatted }}</div>
 
+                               <div class="file-size">{{ data.filesizeHumanReadable }}</div>
                                <# if ( 'image' === data.type && ! data.uploading ) { #>
                                        <# if ( data.width && data.height ) { #>
                                                <div class="dimensions">{{ data.width }} &times; {{ data.height }}</div>
                                        <# } #>
 
-                                       <# if ( data.can.save ) { #>
+                                       <# if ( data.can.save && data.sizes ) { #>
                                                <a class="edit-attachment" href="{{ data.editLink }}&amp;image-editor" target="_blank"><?php _e( 'Edit Image' ); ?></a>
                                                <a class="refresh-attachment" href="#"><?php _e( 'Refresh' ); ?></a>
                                        <# } #>
@@ -325,7 +517,11 @@ function wp_print_media_templates() {
 
                                <# if ( ! data.uploading && data.can.remove ) { #>
                                        <?php if ( MEDIA_TRASH ): ?>
-                                               <a class="trash-attachment" href="#"><?php _e( 'Trash' ); ?></a>
+                                       <# if ( 'trash' === data.status ) { #>
+                                               <a class="untrash-attachment" href="#"><?php _e( 'Untrash' ); ?></a>
+                                       <# } else { #>
+                                               <a class="trash-attachment" href="#"><?php _ex( 'Trash', 'verb' ); ?></a>
+                                       <# } #>
                                        <?php else: ?>
                                                <a class="delete-attachment" href="#"><?php _e( 'Delete Permanently' ); ?></a>
                                        <?php endif; ?>
@@ -339,32 +535,47 @@ function wp_print_media_templates() {
                        </div>
                </div>
 
+               <label class="setting" data-setting="url">
+                       <span class="name"><?php _e('URL'); ?></span>
+                       <input type="text" value="{{ data.url }}" readonly />
+               </label>
                <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #>
-                       <label class="setting" data-setting="title">
-                               <span><?php _e('Title'); ?></span>
-                               <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} />
-                       </label>
-                       <label class="setting" data-setting="caption">
-                               <span><?php _e('Caption'); ?></span>
-                               <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea>
-                       </label>
+               <label class="setting" data-setting="title">
+                       <span class="name"><?php _e('Title'); ?></span>
+                       <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} />
+               </label>
+               <# if ( 'audio' === data.type ) { #>
+               <?php foreach ( array(
+                       'artist' => __( 'Artist' ),
+                       'album' => __( 'Album' ),
+               ) as $key => $label ) : ?>
+               <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>">
+                       <span class="name"><?php echo $label ?></span>
+                       <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" />
+               </label>
+               <?php endforeach; ?>
+               <# } #>
+               <label class="setting" data-setting="caption">
+                       <span class="name"><?php _e('Caption'); ?></span>
+                       <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea>
+               </label>
                <# if ( 'image' === data.type ) { #>
                        <label class="setting" data-setting="alt">
-                               <span><?php _e('Alt Text'); ?></span>
+                               <span class="name"><?php _e('Alt Text'); ?></span>
                                <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} />
                        </label>
                <# } #>
-                       <label class="setting" data-setting="description">
-                               <span><?php _e('Description'); ?></span>
-                               <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea>
-                       </label>
+               <label class="setting" data-setting="description">
+                       <span class="name"><?php _e('Description'); ?></span>
+                       <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea>
+               </label>
        </script>
 
        <script type="text/html" id="tmpl-media-selection">
                <div class="selection-info">
                        <span class="count"></span>
                        <# if ( data.editable ) { #>
-                               <a class="edit-selection" href="#"><?php _e('Edit'); ?></a>
+                               <a class="edit-selection" href="#"><?php _e( 'Edit Selection' ); ?></a>
                        <# } #>
                        <# if ( data.clearable ) { #>
                                <a class="clear-selection" href="#"><?php _e('Clear'); ?></a>
@@ -491,13 +702,15 @@ function wp_print_media_templates() {
                                        data-user-setting="urlbutton"
                                <# } #>>
 
-                               <option value="post" selected>
+                               <option value="post" <# if ( ! wp.media.galleryDefaults.link || 'post' == wp.media.galleryDefaults.link ) {
+                                       #>selected="selected"<# }
+                               #>>
                                        <?php esc_attr_e('Attachment Page'); ?>
                                </option>
-                               <option value="file">
+                               <option value="file" <# if ( 'file' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>>
                                        <?php esc_attr_e('Media File'); ?>
                                </option>
-                               <option value="none">
+                               <option value="none" <# if ( 'none' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>>
                                        <?php esc_attr_e('None'); ?>
                                </option>
                        </select>
@@ -508,7 +721,9 @@ function wp_print_media_templates() {
                        <select class="columns" name="columns"
                                data-setting="columns">
                                <?php for ( $i = 1; $i <= 9; $i++ ) : ?>
-                                       <option value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, 3 ); ?>>
+                                       <option value="<?php echo esc_attr( $i ); ?>" <#
+                                               if ( <?php echo $i ?> == wp.media.galleryDefaults.columns ) { #>selected="selected"<# }
+                                       #>>
                                                <?php echo esc_html( $i ); ?>
                                        </option>
                                <?php endfor; ?>
@@ -519,6 +734,31 @@ function wp_print_media_templates() {
                        <span><?php _e( 'Random Order' ); ?></span>
                        <input type="checkbox" data-setting="_orderbyRandom" />
                </label>
+
+               <label class="setting size">
+                       <span><?php _e( 'Size' ); ?></span>
+                       <select class="size" name="size"
+                               data-setting="size"
+                               <# if ( data.userSettings ) { #>
+                                       data-user-setting="imgsize"
+                               <# } #>
+                               >
+                               <?php
+                               // This filter is documented in wp-admin/includes/media.php
+                               $size_names = apply_filters( 'image_size_names_choose', array(
+                                       'thumbnail' => __( 'Thumbnail' ),
+                                       'medium'    => __( 'Medium' ),
+                                       'large'     => __( 'Large' ),
+                                       'full'      => __( 'Full Size' ),
+                               ) );
+
+                               foreach ( $size_names as $size => $label ) : ?>
+                                       <option value="<?php echo esc_attr( $size ); ?>">
+                                               <?php echo esc_html( $label ); ?>
+                                       </option>
+                               <?php endforeach; ?>
+                       </select>
+               </label>
        </script>
 
        <script type="text/html" id="tmpl-playlist-settings">
@@ -556,10 +796,13 @@ function wp_print_media_templates() {
        </script>
 
        <script type="text/html" id="tmpl-embed-link-settings">
-               <label class="setting">
-                       <span><?php _e('Title'); ?></span>
+               <label class="setting title">
+                       <span><?php _e( 'Title' ); ?></span>
                        <input type="text" class="alignment" data-setting="title" />
                </label>
+               <div class="embed-container" style="display: none;">
+                       <div class="embed-preview"></div>
+               </div>
        </script>
 
        <script type="text/html" id="tmpl-embed-image-settings">
@@ -616,35 +859,6 @@ function wp_print_media_templates() {
                </div>
        </script>
 
-       <script type="text/html" id="tmpl-attachments-css">
-               <style type="text/css" id="{{ data.id }}-css">
-                       #{{ data.id }} {
-                               padding: 0 {{ data.gutter }}px;
-                       }
-
-                       #{{ data.id }} .attachment {
-                               margin: {{ data.gutter }}px;
-                               width: {{ data.edge }}px;
-                       }
-
-                       #{{ data.id }} .attachment-preview,
-                       #{{ data.id }} .attachment-preview .thumbnail {
-                               width: {{ data.edge }}px;
-                               height: {{ data.edge }}px;
-                       }
-
-                       #{{ data.id }} .portrait .thumbnail img {
-                               max-width: {{ data.edge }}px;
-                               height: auto;
-                       }
-
-                       #{{ data.id }} .landscape .thumbnail img {
-                               width: auto;
-                               max-height: {{ data.edge }}px;
-                       }
-               </style>
-       </script>
-
        <script type="text/html" id="tmpl-image-details">
                <div class="media-embed">
                        <div class="embed-media-settings">
@@ -976,9 +1190,6 @@ function wp_print_media_templates() {
        </script>
 
        <script type="text/html" id="tmpl-editor-gallery">
-               <div class="toolbar">
-                       <div class="dashicons dashicons-edit edit"></div><div class="dashicons dashicons-no-alt remove"></div>
-               </div>
                <# if ( data.attachments ) { #>
                        <div class="gallery gallery-columns-{{ data.columns }}">
                                <# _.each( data.attachments, function( attachment, index ) { #>
@@ -990,9 +1201,11 @@ function wp_print_media_templates() {
                                                                <img src="{{ attachment.url }}" />
                                                        <# } #>
                                                </dt>
-                                               <dd class="wp-caption-text gallery-caption">
-                                                       {{ attachment.caption }}
-                                               </dd>
+                                               <# if ( attachment.caption ) { #>
+                                                       <dd class="wp-caption-text gallery-caption">
+                                                               {{ attachment.caption }}
+                                                       </dd>
+                                               <# } #>
                                        </dl>
                                        <# if ( index % data.columns === data.columns - 1 ) { #>
                                                <br style="clear: both;">
@@ -1006,50 +1219,6 @@ function wp_print_media_templates() {
                <# } #>
        </script>
 
-       <script type="text/html" id="tmpl-editor-audio">
-               <div class="toolbar">
-                       <div class="dashicons dashicons-edit edit"></div>
-                       <div class="dashicons dashicons-no-alt remove"></div>
-               </div>
-               <?php wp_underscore_audio_template() ?>
-               <div class="wpview-overlay"></div>
-       </script>
-
-       <script type="text/html" id="tmpl-editor-video">
-               <div class="toolbar">
-                       <div class="dashicons dashicons-edit edit"></div>
-                       <div class="dashicons dashicons-no-alt remove"></div>
-               </div>
-               <?php wp_underscore_video_template() ?>
-               <div class="wpview-overlay"></div>
-       </script>
-
-       <?php wp_underscore_playlist_templates() ?>
-
-       <script type="text/html" id="tmpl-editor-playlist">
-               <div class="toolbar">
-                       <div class="dashicons dashicons-edit edit"></div>
-                       <div class="dashicons dashicons-no-alt remove"></div>
-               </div>
-               <# if ( data.tracks ) { #>
-                       <div class="wp-playlist wp-{{ data.type }}-playlist wp-playlist-{{ data.style }}">
-                               <# if ( 'audio' === data.type ){ #>
-                               <div class="wp-playlist-current-item"></div>
-                               <# } #>
-                               <{{ data.type }} controls="controls" preload="none" <#
-                                       if ( data.width ) { #> width="{{ data.width }}"<# }
-                                       #><# if ( data.height ) { #> height="{{ data.height }}"<# } #>></{{ data.type }}>
-                               <div class="wp-playlist-next"></div>
-                               <div class="wp-playlist-prev"></div>
-                       </div>
-                       <div class="wpview-overlay"></div>
-               <# } else { #>
-                       <div class="wpview-error">
-                               <div class="dashicons dashicons-video-alt3"></div><p><?php _e( 'No items found.' ); ?></p>
-                       </div>
-               <# } #>
-       </script>
-
        <script type="text/html" id="tmpl-crop-content">
                <img class="crop-image" src="{{ data.url }}">
                <div class="upload-errors"></div>