WordPress 4.7
[autoinstalls/wordpress.git] / wp-includes / media-template.php
1 <?php
2 /**
3  * WordPress media templates.
4  *
5  * @package WordPress
6  * @subpackage Media
7  * @since 3.5.0
8  */
9
10 /**
11  * Output the markup for a audio tag to be used in an Underscore template
12  * when data.model is passed.
13  *
14  * @since 3.9.0
15  */
16 function wp_underscore_audio_template() {
17         $audio_types = wp_get_audio_extensions();
18 ?>
19 <audio style="visibility: hidden"
20         controls
21         class="wp-audio-shortcode"
22         width="{{ _.isUndefined( data.model.width ) ? 400 : data.model.width }}"
23         preload="{{ _.isUndefined( data.model.preload ) ? 'none' : data.model.preload }}"
24         <#
25         <?php foreach ( array( 'autoplay', 'loop' ) as $attr ):
26         ?>if ( ! _.isUndefined( data.model.<?php echo $attr ?> ) && data.model.<?php echo $attr ?> ) {
27                 #> <?php echo $attr ?><#
28         }
29         <?php endforeach ?>#>
30 >
31         <# if ( ! _.isEmpty( data.model.src ) ) { #>
32         <source src="{{ data.model.src }}" type="{{ wp.media.view.settings.embedMimes[ data.model.src.split('.').pop() ] }}" />
33         <# } #>
34
35         <?php foreach ( $audio_types as $type ):
36         ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) { #>
37         <source src="{{ data.model.<?php echo $type ?> }}" type="{{ wp.media.view.settings.embedMimes[ '<?php echo $type ?>' ] }}" />
38         <# } #>
39         <?php endforeach;
40 ?></audio>
41 <?php
42 }
43
44 /**
45  * Output the markup for a video tag to be used in an Underscore template
46  * when data.model is passed.
47  *
48  * @since 3.9.0
49  */
50 function wp_underscore_video_template() {
51         $video_types = wp_get_video_extensions();
52 ?>
53 <#  var w_rule = '', classes = [],
54                 w, h, settings = wp.media.view.settings,
55                 isYouTube = isVimeo = false;
56
57         if ( ! _.isEmpty( data.model.src ) ) {
58                 isYouTube = data.model.src.match(/youtube|youtu\.be/);
59                 isVimeo = -1 !== data.model.src.indexOf('vimeo');
60         }
61
62         if ( settings.contentWidth && data.model.width >= settings.contentWidth ) {
63                 w = settings.contentWidth;
64         } else {
65                 w = data.model.width;
66         }
67
68         if ( w !== data.model.width ) {
69                 h = Math.ceil( ( data.model.height * w ) / data.model.width );
70         } else {
71                 h = data.model.height;
72         }
73
74         if ( w ) {
75                 w_rule = 'width: ' + w + 'px; ';
76         }
77
78         if ( isYouTube ) {
79                 classes.push( 'youtube-video' );
80         }
81
82         if ( isVimeo ) {
83                 classes.push( 'vimeo-video' );
84         }
85
86 #>
87 <div style="{{ w_rule }}" class="wp-video">
88 <video controls
89         class="wp-video-shortcode {{ classes.join( ' ' ) }}"
90         <# if ( w ) { #>width="{{ w }}"<# } #>
91         <# if ( h ) { #>height="{{ h }}"<# } #>
92         <?php
93         $props = array( 'poster' => '', 'preload' => 'metadata' );
94         foreach ( $props as $key => $value ):
95                 if ( empty( $value ) ) {
96                 ?><#
97                 if ( ! _.isUndefined( data.model.<?php echo $key ?> ) && data.model.<?php echo $key ?> ) {
98                         #> <?php echo $key ?>="{{ data.model.<?php echo $key ?> }}"<#
99                 } #>
100                 <?php } else {
101                         echo $key ?>="{{ _.isUndefined( data.model.<?php echo $key ?> ) ? '<?php echo $value ?>' : data.model.<?php echo $key ?> }}"<?php
102                 }
103         endforeach;
104         ?><#
105         <?php foreach ( array( 'autoplay', 'loop' ) as $attr ):
106         ?> if ( ! _.isUndefined( data.model.<?php echo $attr ?> ) && data.model.<?php echo $attr ?> ) {
107                 #> <?php echo $attr ?><#
108         }
109         <?php endforeach ?>#>
110 >
111         <# if ( ! _.isEmpty( data.model.src ) ) {
112                 if ( isYouTube ) { #>
113                 <source src="{{ data.model.src }}" type="video/youtube" />
114                 <# } else if ( isVimeo ) { #>
115                 <source src="{{ data.model.src }}" type="video/vimeo" />
116                 <# } else { #>
117                 <source src="{{ data.model.src }}" type="{{ settings.embedMimes[ data.model.src.split('.').pop() ] }}" />
118                 <# }
119         } #>
120
121         <?php foreach ( $video_types as $type ):
122         ?><# if ( data.model.<?php echo $type ?> ) { #>
123         <source src="{{ data.model.<?php echo $type ?> }}" type="{{ settings.embedMimes[ '<?php echo $type ?>' ] }}" />
124         <# } #>
125         <?php endforeach; ?>
126         {{{ data.model.content }}}
127 </video>
128 </div>
129 <?php
130 }
131
132 /**
133  * Prints the templates used in the media manager.
134  *
135  * @since 3.5.0
136  *
137  * @global bool $is_IE
138  */
139 function wp_print_media_templates() {
140         global $is_IE;
141         $class = 'media-modal wp-core-ui';
142         if ( $is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false )
143                 $class .= ' ie7';
144         ?>
145         <!--[if lte IE 8]>
146         <style>
147                 .attachment:focus {
148                         outline: #1e8cbe solid;
149                 }
150                 .selected.attachment {
151                         outline: #1e8cbe solid;
152                 }
153         </style>
154         <![endif]-->
155         <script type="text/html" id="tmpl-media-frame">
156                 <div class="media-frame-menu"></div>
157                 <div class="media-frame-title"></div>
158                 <div class="media-frame-router"></div>
159                 <div class="media-frame-content"></div>
160                 <div class="media-frame-toolbar"></div>
161                 <div class="media-frame-uploader"></div>
162         </script>
163
164         <script type="text/html" id="tmpl-media-modal">
165                 <div class="<?php echo $class; ?>">
166                         <button type="button" class="button-link media-modal-close"><span class="media-modal-icon"><span class="screen-reader-text"><?php _e( 'Close media panel' ); ?></span></span></button>
167                         <div class="media-modal-content"></div>
168                 </div>
169                 <div class="media-modal-backdrop"></div>
170         </script>
171
172         <script type="text/html" id="tmpl-uploader-window">
173                 <div class="uploader-window-content">
174                         <h1><?php _e( 'Drop files to upload' ); ?></h1>
175                 </div>
176         </script>
177
178         <script type="text/html" id="tmpl-uploader-editor">
179                 <div class="uploader-editor-content">
180                         <div class="uploader-editor-title"><?php _e( 'Drop files to upload' ); ?></div>
181                 </div>
182         </script>
183
184         <script type="text/html" id="tmpl-uploader-inline">
185                 <# var messageClass = data.message ? 'has-upload-message' : 'no-upload-message'; #>
186                 <# if ( data.canClose ) { #>
187                 <button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close uploader' ); ?></span></button>
188                 <# } #>
189                 <div class="uploader-inline-content {{ messageClass }}">
190                 <# if ( data.message ) { #>
191                         <h2 class="upload-message">{{ data.message }}</h2>
192                 <# } #>
193                 <?php if ( ! _device_can_upload() ) : ?>
194                         <h2 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/' ); ?></h2>
195                 <?php elseif ( is_multisite() && ! is_upload_space_available() ) : ?>
196                         <h2 class="upload-instructions"><?php _e( 'Upload Limit Exceeded' ); ?></h2>
197                         <?php
198                         /** This action is documented in wp-admin/includes/media.php */
199                         do_action( 'upload_ui_over_quota' ); ?>
200
201                 <?php else : ?>
202                         <div class="upload-ui">
203                                 <h2 class="upload-instructions drop-instructions"><?php _e( 'Drop files anywhere to upload' ); ?></h2>
204                                 <p class="upload-instructions drop-instructions"><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p>
205                                 <button type="button" class="browser button button-hero"><?php _e( 'Select Files' ); ?></button>
206                         </div>
207
208                         <div class="upload-inline-status"></div>
209
210                         <div class="post-upload-ui">
211                                 <?php
212                                 /** This action is documented in wp-admin/includes/media.php */
213                                 do_action( 'pre-upload-ui' );
214                                 /** This action is documented in wp-admin/includes/media.php */
215                                 do_action( 'pre-plupload-upload-ui' );
216
217                                 if ( 10 === remove_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ) ) {
218                                         /** This action is documented in wp-admin/includes/media.php */
219                                         do_action( 'post-plupload-upload-ui' );
220                                         add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' );
221                                 } else {
222                                         /** This action is documented in wp-admin/includes/media.php */
223                                         do_action( 'post-plupload-upload-ui' );
224                                 }
225
226                                 $max_upload_size = wp_max_upload_size();
227                                 if ( ! $max_upload_size ) {
228                                         $max_upload_size = 0;
229                                 }
230                                 ?>
231
232                                 <p class="max-upload-size"><?php
233                                         printf( __( 'Maximum upload file size: %s.' ), esc_html( size_format( $max_upload_size ) ) );
234                                 ?></p>
235
236                                 <# if ( data.suggestedWidth && data.suggestedHeight ) { #>
237                                         <p class="suggested-dimensions">
238                                                 <?php _e( 'Suggested image dimensions:' ); ?> {{data.suggestedWidth}} &times; {{data.suggestedHeight}}
239                                         </p>
240                                 <# } #>
241
242                                 <?php
243                                 /** This action is documented in wp-admin/includes/media.php */
244                                 do_action( 'post-upload-ui' ); ?>
245                         </div>
246                 <?php endif; ?>
247                 </div>
248         </script>
249
250         <script type="text/html" id="tmpl-media-library-view-switcher">
251                 <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-list">
252                         <span class="screen-reader-text"><?php _e( 'List View' ); ?></span>
253                 </a>
254                 <a href="<?php echo esc_url( add_query_arg( 'mode', 'grid', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-grid current">
255                         <span class="screen-reader-text"><?php _e( 'Grid View' ); ?></span>
256                 </a>
257         </script>
258
259         <script type="text/html" id="tmpl-uploader-status">
260                 <h2><?php _e( 'Uploading' ); ?></h2>
261                 <button type="button" class="button-link upload-dismiss-errors"><span class="screen-reader-text"><?php _e( 'Dismiss Errors' ); ?></span></button>
262
263                 <div class="media-progress-bar"><div></div></div>
264                 <div class="upload-details">
265                         <span class="upload-count">
266                                 <span class="upload-index"></span> / <span class="upload-total"></span>
267                         </span>
268                         <span class="upload-detail-separator">&ndash;</span>
269                         <span class="upload-filename"></span>
270                 </div>
271                 <div class="upload-errors"></div>
272         </script>
273
274         <script type="text/html" id="tmpl-uploader-status-error">
275                 <span class="upload-error-filename">{{{ data.filename }}}</span>
276                 <span class="upload-error-message">{{ data.message }}</span>
277         </script>
278
279         <script type="text/html" id="tmpl-edit-attachment-frame">
280                 <div class="edit-media-header">
281                         <button class="left dashicons <# if ( ! data.hasPrevious ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit previous media item' ); ?></span></button>
282                         <button class="right dashicons <# if ( ! data.hasNext ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit next media item' ); ?></span></button>
283                 </div>
284                 <div class="media-frame-title"></div>
285                 <div class="media-frame-content"></div>
286         </script>
287
288         <script type="text/html" id="tmpl-attachment-details-two-column">
289                 <div class="attachment-media-view {{ data.orientation }}">
290                         <div class="thumbnail thumbnail-{{ data.type }}">
291                                 <# if ( data.uploading ) { #>
292                                         <div class="media-progress-bar"><div></div></div>
293                                 <# } else if ( data.sizes && data.sizes.large ) { #>
294                                         <img class="details-image" src="{{ data.sizes.large.url }}" draggable="false" alt="" />
295                                 <# } else if ( data.sizes && data.sizes.full ) { #>
296                                         <img class="details-image" src="{{ data.sizes.full.url }}" draggable="false" alt="" />
297                                 <# } else if ( -1 === jQuery.inArray( data.type, [ 'audio', 'video' ] ) ) { #>
298                                         <img class="details-image icon" src="{{ data.icon }}" draggable="false" alt="" />
299                                 <# } #>
300
301                                 <# if ( 'audio' === data.type ) { #>
302                                 <div class="wp-media-wrapper">
303                                         <audio style="visibility: hidden" controls class="wp-audio-shortcode" width="100%" preload="none">
304                                                 <source type="{{ data.mime }}" src="{{ data.url }}"/>
305                                         </audio>
306                                 </div>
307                                 <# } else if ( 'video' === data.type ) {
308                                         var w_rule = '';
309                                         if ( data.width ) {
310                                                 w_rule = 'width: ' + data.width + 'px;';
311                                         } else if ( wp.media.view.settings.contentWidth ) {
312                                                 w_rule = 'width: ' + wp.media.view.settings.contentWidth + 'px;';
313                                         }
314                                 #>
315                                 <div style="{{ w_rule }}" class="wp-media-wrapper wp-video">
316                                         <video controls="controls" class="wp-video-shortcode" preload="metadata"
317                                                 <# if ( data.width ) { #>width="{{ data.width }}"<# } #>
318                                                 <# if ( data.height ) { #>height="{{ data.height }}"<# } #>
319                                                 <# if ( data.image && data.image.src !== data.icon ) { #>poster="{{ data.image.src }}"<# } #>>
320                                                 <source type="{{ data.mime }}" src="{{ data.url }}"/>
321                                         </video>
322                                 </div>
323                                 <# } #>
324
325                                 <div class="attachment-actions">
326                                         <# if ( 'image' === data.type && ! data.uploading && data.sizes && data.can.save ) { #>
327                                         <button type="button" class="button edit-attachment"><?php _e( 'Edit Image' ); ?></button>
328                                         <# } else if ( 'pdf' === data.subtype && data.sizes ) { #>
329                                         <?php _e( 'Document Preview' ); ?>
330                                         <# } #>
331                                 </div>
332                         </div>
333                 </div>
334                 <div class="attachment-info">
335                         <span class="settings-save-status">
336                                 <span class="spinner"></span>
337                                 <span class="saved"><?php esc_html_e('Saved.'); ?></span>
338                         </span>
339                         <div class="details">
340                                 <div class="filename"><strong><?php _e( 'File name:' ); ?></strong> {{ data.filename }}</div>
341                                 <div class="filename"><strong><?php _e( 'File type:' ); ?></strong> {{ data.mime }}</div>
342                                 <div class="uploaded"><strong><?php _e( 'Uploaded on:' ); ?></strong> {{ data.dateFormatted }}</div>
343
344                                 <div class="file-size"><strong><?php _e( 'File size:' ); ?></strong> {{ data.filesizeHumanReadable }}</div>
345                                 <# if ( 'image' === data.type && ! data.uploading ) { #>
346                                         <# if ( data.width && data.height ) { #>
347                                                 <div class="dimensions"><strong><?php _e( 'Dimensions:' ); ?></strong> {{ data.width }} &times; {{ data.height }}</div>
348                                         <# } #>
349                                 <# } #>
350
351                                 <# if ( data.fileLength ) { #>
352                                         <div class="file-length"><strong><?php _e( 'Length:' ); ?></strong> {{ data.fileLength }}</div>
353                                 <# } #>
354
355                                 <# if ( 'audio' === data.type && data.meta.bitrate ) { #>
356                                         <div class="bitrate">
357                                                 <strong><?php _e( 'Bitrate:' ); ?></strong> {{ Math.round( data.meta.bitrate / 1000 ) }}kb/s
358                                                 <# if ( data.meta.bitrate_mode ) { #>
359                                                 {{ ' ' + data.meta.bitrate_mode.toUpperCase() }}
360                                                 <# } #>
361                                         </div>
362                                 <# } #>
363
364                                 <div class="compat-meta">
365                                         <# if ( data.compat && data.compat.meta ) { #>
366                                                 {{{ data.compat.meta }}}
367                                         <# } #>
368                                 </div>
369                         </div>
370
371                         <div class="settings">
372                                 <label class="setting" data-setting="url">
373                                         <span class="name"><?php _e('URL'); ?></span>
374                                         <input type="text" value="{{ data.url }}" readonly />
375                                 </label>
376                                 <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #>
377                                 <?php if ( post_type_supports( 'attachment', 'title' ) ) : ?>
378                                 <label class="setting" data-setting="title">
379                                         <span class="name"><?php _e('Title'); ?></span>
380                                         <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} />
381                                 </label>
382                                 <?php endif; ?>
383                                 <# if ( 'audio' === data.type ) { #>
384                                 <?php foreach ( array(
385                                         'artist' => __( 'Artist' ),
386                                         'album' => __( 'Album' ),
387                                 ) as $key => $label ) : ?>
388                                 <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>">
389                                         <span class="name"><?php echo $label ?></span>
390                                         <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" />
391                                 </label>
392                                 <?php endforeach; ?>
393                                 <# } #>
394                                 <label class="setting" data-setting="caption">
395                                         <span class="name"><?php _e( 'Caption' ); ?></span>
396                                         <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea>
397                                 </label>
398                                 <# if ( 'image' === data.type ) { #>
399                                         <label class="setting" data-setting="alt">
400                                                 <span class="name"><?php _e( 'Alt Text' ); ?></span>
401                                                 <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} />
402                                         </label>
403                                 <# } #>
404                                 <label class="setting" data-setting="description">
405                                         <span class="name"><?php _e('Description'); ?></span>
406                                         <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea>
407                                 </label>
408                                 <label class="setting">
409                                         <span class="name"><?php _e( 'Uploaded By' ); ?></span>
410                                         <span class="value">{{ data.authorName }}</span>
411                                 </label>
412                                 <# if ( data.uploadedToTitle ) { #>
413                                         <label class="setting">
414                                                 <span class="name"><?php _e( 'Uploaded To' ); ?></span>
415                                                 <# if ( data.uploadedToLink ) { #>
416                                                         <span class="value"><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a></span>
417                                                 <# } else { #>
418                                                         <span class="value">{{ data.uploadedToTitle }}</span>
419                                                 <# } #>
420                                         </label>
421                                 <# } #>
422                                 <div class="attachment-compat"></div>
423                         </div>
424
425                         <div class="actions">
426                                 <a class="view-attachment" href="{{ data.link }}"><?php _e( 'View attachment page' ); ?></a>
427                                 <# if ( data.can.save ) { #> |
428                                         <a href="post.php?post={{ data.id }}&action=edit"><?php _e( 'Edit more details' ); ?></a>
429                                 <# } #>
430                                 <# if ( ! data.uploading && data.can.remove ) { #> |
431                                         <?php if ( MEDIA_TRASH ): ?>
432                                                 <# if ( 'trash' === data.status ) { #>
433                                                         <button type="button" class="button-link untrash-attachment"><?php _e( 'Untrash' ); ?></button>
434                                                 <# } else { #>
435                                                         <button type="button" class="button-link trash-attachment"><?php _ex( 'Trash', 'verb' ); ?></button>
436                                                 <# } #>
437                                         <?php else: ?>
438                                                 <button type="button" class="button-link delete-attachment"><?php _e( 'Delete Permanently' ); ?></button>
439                                         <?php endif; ?>
440                                 <# } #>
441                         </div>
442
443                 </div>
444         </script>
445
446         <script type="text/html" id="tmpl-attachment">
447                 <div class="attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">
448                         <div class="thumbnail">
449                                 <# if ( data.uploading ) { #>
450                                         <div class="media-progress-bar"><div style="width: {{ data.percent }}%"></div></div>
451                                 <# } else if ( 'image' === data.type && data.sizes ) { #>
452                                         <div class="centered">
453                                                 <img src="{{ data.size.url }}" draggable="false" alt="" />
454                                         </div>
455                                 <# } else { #>
456                                         <div class="centered">
457                                                 <# if ( data.image && data.image.src && data.image.src !== data.icon ) { #>
458                                                         <img src="{{ data.image.src }}" class="thumbnail" draggable="false" alt="" />
459                                                 <# } else if ( data.sizes && data.sizes.medium ) { #>
460                                                         <img src="{{ data.sizes.medium.url }}" class="thumbnail" draggable="false" alt="" />
461                                                 <# } else { #>
462                                                         <img src="{{ data.icon }}" class="icon" draggable="false" alt="" />
463                                                 <# } #>
464                                         </div>
465                                         <div class="filename">
466                                                 <div>{{ data.filename }}</div>
467                                         </div>
468                                 <# } #>
469                         </div>
470                         <# if ( data.buttons.close ) { #>
471                                 <button type="button" class="button-link attachment-close media-modal-icon"><span class="screen-reader-text"><?php _e( 'Remove' ); ?></span></button>
472                         <# } #>
473                 </div>
474                 <# if ( data.buttons.check ) { #>
475                         <button type="button" class="button-link check" tabindex="-1"><span class="media-modal-icon"></span><span class="screen-reader-text"><?php _e( 'Deselect' ); ?></span></button>
476                 <# } #>
477                 <#
478                 var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly';
479                 if ( data.describe ) {
480                         if ( 'image' === data.type ) { #>
481                                 <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption"
482                                         placeholder="<?php esc_attr_e('Caption this image&hellip;'); ?>" {{ maybeReadOnly }} />
483                         <# } else { #>
484                                 <input type="text" value="{{ data.title }}" class="describe" data-setting="title"
485                                         <# if ( 'video' === data.type ) { #>
486                                                 placeholder="<?php esc_attr_e('Describe this video&hellip;'); ?>"
487                                         <# } else if ( 'audio' === data.type ) { #>
488                                                 placeholder="<?php esc_attr_e('Describe this audio file&hellip;'); ?>"
489                                         <# } else { #>
490                                                 placeholder="<?php esc_attr_e('Describe this media file&hellip;'); ?>"
491                                         <# } #> {{ maybeReadOnly }} />
492                         <# }
493                 } #>
494         </script>
495
496         <script type="text/html" id="tmpl-attachment-details">
497                 <h2>
498                         <?php _e( 'Attachment Details' ); ?>
499                         <span class="settings-save-status">
500                                 <span class="spinner"></span>
501                                 <span class="saved"><?php esc_html_e('Saved.'); ?></span>
502                         </span>
503                 </h2>
504                 <div class="attachment-info">
505                         <div class="thumbnail thumbnail-{{ data.type }}">
506                                 <# if ( data.uploading ) { #>
507                                         <div class="media-progress-bar"><div></div></div>
508                                 <# } else if ( 'image' === data.type && data.sizes ) { #>
509                                         <img src="{{ data.size.url }}" draggable="false" alt="" />
510                                 <# } else { #>
511                                         <img src="{{ data.icon }}" class="icon" draggable="false" alt="" />
512                                 <# } #>
513                         </div>
514                         <div class="details">
515                                 <div class="filename">{{ data.filename }}</div>
516                                 <div class="uploaded">{{ data.dateFormatted }}</div>
517
518                                 <div class="file-size">{{ data.filesizeHumanReadable }}</div>
519                                 <# if ( 'image' === data.type && ! data.uploading ) { #>
520                                         <# if ( data.width && data.height ) { #>
521                                                 <div class="dimensions">{{ data.width }} &times; {{ data.height }}</div>
522                                         <# } #>
523
524                                         <# if ( data.can.save && data.sizes ) { #>
525                                                 <a class="edit-attachment" href="{{ data.editLink }}&amp;image-editor" target="_blank"><?php _e( 'Edit Image' ); ?></a>
526                                         <# } #>
527                                 <# } #>
528
529                                 <# if ( data.fileLength ) { #>
530                                         <div class="file-length"><?php _e( 'Length:' ); ?> {{ data.fileLength }}</div>
531                                 <# } #>
532
533                                 <# if ( ! data.uploading && data.can.remove ) { #>
534                                         <?php if ( MEDIA_TRASH ): ?>
535                                         <# if ( 'trash' === data.status ) { #>
536                                                 <button type="button" class="button-link untrash-attachment"><?php _e( 'Untrash' ); ?></button>
537                                         <# } else { #>
538                                                 <button type="button" class="button-link trash-attachment"><?php _ex( 'Trash', 'verb' ); ?></button>
539                                         <# } #>
540                                         <?php else: ?>
541                                                 <button type="button" class="button-link delete-attachment"><?php _e( 'Delete Permanently' ); ?></button>
542                                         <?php endif; ?>
543                                 <# } #>
544
545                                 <div class="compat-meta">
546                                         <# if ( data.compat && data.compat.meta ) { #>
547                                                 {{{ data.compat.meta }}}
548                                         <# } #>
549                                 </div>
550                         </div>
551                 </div>
552
553                 <label class="setting" data-setting="url">
554                         <span class="name"><?php _e('URL'); ?></span>
555                         <input type="text" value="{{ data.url }}" readonly />
556                 </label>
557                 <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #>
558                 <?php if ( post_type_supports( 'attachment', 'title' ) ) : ?>
559                 <label class="setting" data-setting="title">
560                         <span class="name"><?php _e('Title'); ?></span>
561                         <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} />
562                 </label>
563                 <?php endif; ?>
564                 <# if ( 'audio' === data.type ) { #>
565                 <?php foreach ( array(
566                         'artist' => __( 'Artist' ),
567                         'album' => __( 'Album' ),
568                 ) as $key => $label ) : ?>
569                 <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>">
570                         <span class="name"><?php echo $label ?></span>
571                         <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" />
572                 </label>
573                 <?php endforeach; ?>
574                 <# } #>
575                 <label class="setting" data-setting="caption">
576                         <span class="name"><?php _e('Caption'); ?></span>
577                         <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea>
578                 </label>
579                 <# if ( 'image' === data.type ) { #>
580                         <label class="setting" data-setting="alt">
581                                 <span class="name"><?php _e('Alt Text'); ?></span>
582                                 <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} />
583                         </label>
584                 <# } #>
585                 <label class="setting" data-setting="description">
586                         <span class="name"><?php _e('Description'); ?></span>
587                         <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea>
588                 </label>
589         </script>
590
591         <script type="text/html" id="tmpl-media-selection">
592                 <div class="selection-info">
593                         <span class="count"></span>
594                         <# if ( data.editable ) { #>
595                                 <button type="button" class="button-link edit-selection"><?php _e( 'Edit Selection' ); ?></button>
596                         <# } #>
597                         <# if ( data.clearable ) { #>
598                                 <button type="button" class="button-link clear-selection"><?php _e( 'Clear' ); ?></button>
599                         <# } #>
600                 </div>
601                 <div class="selection-view"></div>
602         </script>
603
604         <script type="text/html" id="tmpl-attachment-display-settings">
605                 <h2><?php _e( 'Attachment Display Settings' ); ?></h2>
606
607                 <# if ( 'image' === data.type ) { #>
608                         <label class="setting">
609                                 <span><?php _e('Alignment'); ?></span>
610                                 <select class="alignment"
611                                         data-setting="align"
612                                         <# if ( data.userSettings ) { #>
613                                                 data-user-setting="align"
614                                         <# } #>>
615
616                                         <option value="left">
617                                                 <?php esc_html_e( 'Left' ); ?>
618                                         </option>
619                                         <option value="center">
620                                                 <?php esc_html_e( 'Center' ); ?>
621                                         </option>
622                                         <option value="right">
623                                                 <?php esc_html_e( 'Right' ); ?>
624                                         </option>
625                                         <option value="none" selected>
626                                                 <?php esc_html_e( 'None' ); ?>
627                                         </option>
628                                 </select>
629                         </label>
630                 <# } #>
631
632                 <div class="setting">
633                         <label>
634                                 <# if ( data.model.canEmbed ) { #>
635                                         <span><?php _e('Embed or Link'); ?></span>
636                                 <# } else { #>
637                                         <span><?php _e('Link To'); ?></span>
638                                 <# } #>
639
640                                 <select class="link-to"
641                                         data-setting="link"
642                                         <# if ( data.userSettings && ! data.model.canEmbed ) { #>
643                                                 data-user-setting="urlbutton"
644                                         <# } #>>
645
646                                 <# if ( data.model.canEmbed ) { #>
647                                         <option value="embed" selected>
648                                                 <?php esc_html_e( 'Embed Media Player' ); ?>
649                                         </option>
650                                         <option value="file">
651                                 <# } else { #>
652                                         <option value="none" selected>
653                                                 <?php esc_html_e( 'None' ); ?>
654                                         </option>
655                                         <option value="file">
656                                 <# } #>
657                                         <# if ( data.model.canEmbed ) { #>
658                                                 <?php esc_html_e( 'Link to Media File' ); ?>
659                                         <# } else { #>
660                                                 <?php esc_html_e( 'Media File' ); ?>
661                                         <# } #>
662                                         </option>
663                                         <option value="post">
664                                         <# if ( data.model.canEmbed ) { #>
665                                                 <?php esc_html_e( 'Link to Attachment Page' ); ?>
666                                         <# } else { #>
667                                                 <?php esc_html_e( 'Attachment Page' ); ?>
668                                         <# } #>
669                                         </option>
670                                 <# if ( 'image' === data.type ) { #>
671                                         <option value="custom">
672                                                 <?php esc_html_e( 'Custom URL' ); ?>
673                                         </option>
674                                 <# } #>
675                                 </select>
676                         </label>
677                         <input type="text" class="link-to-custom" data-setting="linkUrl" />
678                 </div>
679
680                 <# if ( 'undefined' !== typeof data.sizes ) { #>
681                         <label class="setting">
682                                 <span><?php _e('Size'); ?></span>
683                                 <select class="size" name="size"
684                                         data-setting="size"
685                                         <# if ( data.userSettings ) { #>
686                                                 data-user-setting="imgsize"
687                                         <# } #>>
688                                         <?php
689                                         /** This filter is documented in wp-admin/includes/media.php */
690                                         $sizes = apply_filters( 'image_size_names_choose', array(
691                                                 'thumbnail' => __('Thumbnail'),
692                                                 'medium'    => __('Medium'),
693                                                 'large'     => __('Large'),
694                                                 'full'      => __('Full Size'),
695                                         ) );
696
697                                         foreach ( $sizes as $value => $name ) : ?>
698                                                 <#
699                                                 var size = data.sizes['<?php echo esc_js( $value ); ?>'];
700                                                 if ( size ) { #>
701                                                         <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'full' ); ?>>
702                                                                 <?php echo esc_html( $name ); ?> &ndash; {{ size.width }} &times; {{ size.height }}
703                                                         </option>
704                                                 <# } #>
705                                         <?php endforeach; ?>
706                                 </select>
707                         </label>
708                 <# } #>
709         </script>
710
711         <script type="text/html" id="tmpl-gallery-settings">
712                 <h2><?php _e( 'Gallery Settings' ); ?></h2>
713
714                 <label class="setting">
715                         <span><?php _e('Link To'); ?></span>
716                         <select class="link-to"
717                                 data-setting="link"
718                                 <# if ( data.userSettings ) { #>
719                                         data-user-setting="urlbutton"
720                                 <# } #>>
721
722                                 <option value="post" <# if ( ! wp.media.galleryDefaults.link || 'post' == wp.media.galleryDefaults.link ) {
723                                         #>selected="selected"<# }
724                                 #>>
725                                         <?php esc_html_e( 'Attachment Page' ); ?>
726                                 </option>
727                                 <option value="file" <# if ( 'file' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>>
728                                         <?php esc_html_e( 'Media File' ); ?>
729                                 </option>
730                                 <option value="none" <# if ( 'none' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>>
731                                         <?php esc_html_e( 'None' ); ?>
732                                 </option>
733                         </select>
734                 </label>
735
736                 <label class="setting">
737                         <span><?php _e('Columns'); ?></span>
738                         <select class="columns" name="columns"
739                                 data-setting="columns">
740                                 <?php for ( $i = 1; $i <= 9; $i++ ) : ?>
741                                         <option value="<?php echo esc_attr( $i ); ?>" <#
742                                                 if ( <?php echo $i ?> == wp.media.galleryDefaults.columns ) { #>selected="selected"<# }
743                                         #>>
744                                                 <?php echo esc_html( $i ); ?>
745                                         </option>
746                                 <?php endfor; ?>
747                         </select>
748                 </label>
749
750                 <label class="setting">
751                         <span><?php _e( 'Random Order' ); ?></span>
752                         <input type="checkbox" data-setting="_orderbyRandom" />
753                 </label>
754
755                 <label class="setting size">
756                         <span><?php _e( 'Size' ); ?></span>
757                         <select class="size" name="size"
758                                 data-setting="size"
759                                 <# if ( data.userSettings ) { #>
760                                         data-user-setting="imgsize"
761                                 <# } #>
762                                 >
763                                 <?php
764                                 // This filter is documented in wp-admin/includes/media.php
765                                 $size_names = apply_filters( 'image_size_names_choose', array(
766                                         'thumbnail' => __( 'Thumbnail' ),
767                                         'medium'    => __( 'Medium' ),
768                                         'large'     => __( 'Large' ),
769                                         'full'      => __( 'Full Size' ),
770                                 ) );
771
772                                 foreach ( $size_names as $size => $label ) : ?>
773                                         <option value="<?php echo esc_attr( $size ); ?>">
774                                                 <?php echo esc_html( $label ); ?>
775                                         </option>
776                                 <?php endforeach; ?>
777                         </select>
778                 </label>
779         </script>
780
781         <script type="text/html" id="tmpl-playlist-settings">
782                 <h2><?php _e( 'Playlist Settings' ); ?></h2>
783
784                 <# var emptyModel = _.isEmpty( data.model ),
785                         isVideo = 'video' === data.controller.get('library').props.get('type'); #>
786
787                 <label class="setting">
788                         <input type="checkbox" data-setting="tracklist" <# if ( emptyModel ) { #>
789                                 checked="checked"
790                         <# } #> />
791                         <# if ( isVideo ) { #>
792                         <span><?php _e( 'Show Video List' ); ?></span>
793                         <# } else { #>
794                         <span><?php _e( 'Show Tracklist' ); ?></span>
795                         <# } #>
796                 </label>
797
798                 <# if ( ! isVideo ) { #>
799                 <label class="setting">
800                         <input type="checkbox" data-setting="artists" <# if ( emptyModel ) { #>
801                                 checked="checked"
802                         <# } #> />
803                         <span><?php _e( 'Show Artist Name in Tracklist' ); ?></span>
804                 </label>
805                 <# } #>
806
807                 <label class="setting">
808                         <input type="checkbox" data-setting="images" <# if ( emptyModel ) { #>
809                                 checked="checked"
810                         <# } #> />
811                         <span><?php _e( 'Show Images' ); ?></span>
812                 </label>
813         </script>
814
815         <script type="text/html" id="tmpl-embed-link-settings">
816                 <label class="setting link-text">
817                         <span><?php _e( 'Link Text' ); ?></span>
818                         <input type="text" class="alignment" data-setting="linkText" />
819                 </label>
820                 <div class="embed-container" style="display: none;">
821                         <div class="embed-preview"></div>
822                 </div>
823         </script>
824
825         <script type="text/html" id="tmpl-embed-image-settings">
826                 <div class="thumbnail">
827                         <img src="{{ data.model.url }}" draggable="false" alt="" />
828                 </div>
829
830                 <?php
831                 /** This filter is documented in wp-admin/includes/media.php */
832                 if ( ! apply_filters( 'disable_captions', '' ) ) : ?>
833                         <label class="setting caption">
834                                 <span><?php _e('Caption'); ?></span>
835                                 <textarea data-setting="caption" />
836                         </label>
837                 <?php endif; ?>
838
839                 <label class="setting alt-text">
840                         <span><?php _e('Alt Text'); ?></span>
841                         <input type="text" data-setting="alt" />
842                 </label>
843
844                 <div class="setting align">
845                         <span><?php _e('Align'); ?></span>
846                         <div class="button-group button-large" data-setting="align">
847                                 <button class="button" value="left">
848                                         <?php esc_html_e( 'Left' ); ?>
849                                 </button>
850                                 <button class="button" value="center">
851                                         <?php esc_html_e( 'Center' ); ?>
852                                 </button>
853                                 <button class="button" value="right">
854                                         <?php esc_html_e( 'Right' ); ?>
855                                 </button>
856                                 <button class="button active" value="none">
857                                         <?php esc_html_e( 'None' ); ?>
858                                 </button>
859                         </div>
860                 </div>
861
862                 <div class="setting link-to">
863                         <span><?php _e('Link To'); ?></span>
864                         <div class="button-group button-large" data-setting="link">
865                                 <button class="button" value="file">
866                                         <?php esc_html_e( 'Image URL' ); ?>
867                                 </button>
868                                 <button class="button" value="custom">
869                                         <?php esc_html_e( 'Custom URL' ); ?>
870                                 </button>
871                                 <button class="button active" value="none">
872                                         <?php esc_html_e( 'None' ); ?>
873                                 </button>
874                         </div>
875                         <input type="text" class="link-to-custom" data-setting="linkUrl" />
876                 </div>
877         </script>
878
879         <script type="text/html" id="tmpl-image-details">
880                 <div class="media-embed">
881                         <div class="embed-media-settings">
882                                 <div class="column-image">
883                                         <div class="image">
884                                                 <img src="{{ data.model.url }}" draggable="false" alt="" />
885
886                                                 <# if ( data.attachment && window.imageEdit ) { #>
887                                                         <div class="actions">
888                                                                 <input type="button" class="edit-attachment button" value="<?php esc_attr_e( 'Edit Original' ); ?>" />
889                                                                 <input type="button" class="replace-attachment button" value="<?php esc_attr_e( 'Replace' ); ?>" />
890                                                         </div>
891                                                 <# } #>
892                                         </div>
893                                 </div>
894                                 <div class="column-settings">
895                                         <?php
896                                         /** This filter is documented in wp-admin/includes/media.php */
897                                         if ( ! apply_filters( 'disable_captions', '' ) ) : ?>
898                                                 <label class="setting caption">
899                                                         <span><?php _e('Caption'); ?></span>
900                                                         <textarea data-setting="caption">{{ data.model.caption }}</textarea>
901                                                 </label>
902                                         <?php endif; ?>
903
904                                         <label class="setting alt-text">
905                                                 <span><?php _e('Alternative Text'); ?></span>
906                                                 <input type="text" data-setting="alt" value="{{ data.model.alt }}" />
907                                         </label>
908
909                                         <h2><?php _e( 'Display Settings' ); ?></h2>
910                                         <div class="setting align">
911                                                 <span><?php _e('Align'); ?></span>
912                                                 <div class="button-group button-large" data-setting="align">
913                                                         <button class="button" value="left">
914                                                                 <?php esc_html_e( 'Left' ); ?>
915                                                         </button>
916                                                         <button class="button" value="center">
917                                                                 <?php esc_html_e( 'Center' ); ?>
918                                                         </button>
919                                                         <button class="button" value="right">
920                                                                 <?php esc_html_e( 'Right' ); ?>
921                                                         </button>
922                                                         <button class="button active" value="none">
923                                                                 <?php esc_html_e( 'None' ); ?>
924                                                         </button>
925                                                 </div>
926                                         </div>
927
928                                         <# if ( data.attachment ) { #>
929                                                 <# if ( 'undefined' !== typeof data.attachment.sizes ) { #>
930                                                         <label class="setting size">
931                                                                 <span><?php _e('Size'); ?></span>
932                                                                 <select class="size" name="size"
933                                                                         data-setting="size"
934                                                                         <# if ( data.userSettings ) { #>
935                                                                                 data-user-setting="imgsize"
936                                                                         <# } #>>
937                                                                         <?php
938                                                                         /** This filter is documented in wp-admin/includes/media.php */
939                                                                         $sizes = apply_filters( 'image_size_names_choose', array(
940                                                                                 'thumbnail' => __('Thumbnail'),
941                                                                                 'medium'    => __('Medium'),
942                                                                                 'large'     => __('Large'),
943                                                                                 'full'      => __('Full Size'),
944                                                                         ) );
945
946                                                                         foreach ( $sizes as $value => $name ) : ?>
947                                                                                 <#
948                                                                                 var size = data.sizes['<?php echo esc_js( $value ); ?>'];
949                                                                                 if ( size ) { #>
950                                                                                         <option value="<?php echo esc_attr( $value ); ?>">
951                                                                                                 <?php echo esc_html( $name ); ?> &ndash; {{ size.width }} &times; {{ size.height }}
952                                                                                         </option>
953                                                                                 <# } #>
954                                                                         <?php endforeach; ?>
955                                                                         <option value="<?php echo esc_attr( 'custom' ); ?>">
956                                                                                 <?php _e( 'Custom Size' ); ?>
957                                                                         </option>
958                                                                 </select>
959                                                         </label>
960                                                 <# } #>
961                                                         <div class="custom-size<# if ( data.model.size !== 'custom' ) { #> hidden<# } #>">
962                                                                 <label><span><?php _e( 'Width' ); ?> <small>(px)</small></span> <input data-setting="customWidth" type="number" step="1" value="{{ data.model.customWidth }}" /></label><span class="sep">&times;</span><label><span><?php _e( 'Height' ); ?> <small>(px)</small></span><input data-setting="customHeight" type="number" step="1" value="{{ data.model.customHeight }}" /></label>
963                                                         </div>
964                                         <# } #>
965
966                                         <div class="setting link-to">
967                                                 <span><?php _e('Link To'); ?></span>
968                                                 <select data-setting="link">
969                                                 <# if ( data.attachment ) { #>
970                                                         <option value="file">
971                                                                 <?php esc_html_e( 'Media File' ); ?>
972                                                         </option>
973                                                         <option value="post">
974                                                                 <?php esc_html_e( 'Attachment Page' ); ?>
975                                                         </option>
976                                                 <# } else { #>
977                                                         <option value="file">
978                                                                 <?php esc_html_e( 'Image URL' ); ?>
979                                                         </option>
980                                                 <# } #>
981                                                         <option value="custom">
982                                                                 <?php esc_html_e( 'Custom URL' ); ?>
983                                                         </option>
984                                                         <option value="none">
985                                                                 <?php esc_html_e( 'None' ); ?>
986                                                         </option>
987                                                 </select>
988                                                 <input type="text" class="link-to-custom" data-setting="linkUrl" />
989                                         </div>
990                                         <div class="advanced-section">
991                                                 <h2><button type="button" class="button-link advanced-toggle"><?php _e( 'Advanced Options' ); ?></button></h2>
992                                                 <div class="advanced-settings hidden">
993                                                         <div class="advanced-image">
994                                                                 <label class="setting title-text">
995                                                                         <span><?php _e('Image Title Attribute'); ?></span>
996                                                                         <input type="text" data-setting="title" value="{{ data.model.title }}" />
997                                                                 </label>
998                                                                 <label class="setting extra-classes">
999                                                                         <span><?php _e('Image CSS Class'); ?></span>
1000                                                                         <input type="text" data-setting="extraClasses" value="{{ data.model.extraClasses }}" />
1001                                                                 </label>
1002                                                         </div>
1003                                                         <div class="advanced-link">
1004                                                                 <div class="setting link-target">
1005                                                                         <label><input type="checkbox" data-setting="linkTargetBlank" value="_blank" <# if ( data.model.linkTargetBlank ) { #>checked="checked"<# } #>><?php _e( 'Open link in a new tab' ); ?></label>
1006                                                                 </div>
1007                                                                 <label class="setting link-rel">
1008                                                                         <span><?php _e('Link Rel'); ?></span>
1009                                                                         <input type="text" data-setting="linkRel" value="{{ data.model.linkClassName }}" />
1010                                                                 </label>
1011                                                                 <label class="setting link-class-name">
1012                                                                         <span><?php _e('Link CSS Class'); ?></span>
1013                                                                         <input type="text" data-setting="linkClassName" value="{{ data.model.linkClassName }}" />
1014                                                                 </label>
1015                                                         </div>
1016                                                 </div>
1017                                         </div>
1018                                 </div>
1019                         </div>
1020                 </div>
1021         </script>
1022
1023         <script type="text/html" id="tmpl-image-editor">
1024                 <div id="media-head-{{ data.id }}"></div>
1025                 <div id="image-editor-{{ data.id }}"></div>
1026         </script>
1027
1028         <script type="text/html" id="tmpl-audio-details">
1029                 <# var ext, html5types = {
1030                         mp3: wp.media.view.settings.embedMimes.mp3,
1031                         ogg: wp.media.view.settings.embedMimes.ogg
1032                 }; #>
1033
1034                 <?php $audio_types = wp_get_audio_extensions(); ?>
1035                 <div class="media-embed media-embed-details">
1036                         <div class="embed-media-settings embed-audio-settings">
1037                                 <?php wp_underscore_audio_template() ?>
1038
1039                                 <# if ( ! _.isEmpty( data.model.src ) ) {
1040                                         ext = data.model.src.split('.').pop();
1041                                         if ( html5types[ ext ] ) {
1042                                                 delete html5types[ ext ];
1043                                         }
1044                                 #>
1045                                 <label class="setting">
1046                                         <span>SRC</span>
1047                                         <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" />
1048                                         <button type="button" class="button-link remove-setting"><?php _e( 'Remove audio source' ); ?></button>
1049                                 </label>
1050                                 <# } #>
1051                                 <?php
1052
1053                                 foreach ( $audio_types as $type ):
1054                                 ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) {
1055                                         if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) {
1056                                                 delete html5types.<?php echo $type ?>;
1057                                         }
1058                                 #>
1059                                 <label class="setting">
1060                                         <span><?php echo strtoupper( $type ) ?></span>
1061                                         <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" />
1062                                         <button type="button" class="button-link remove-setting"><?php _e( 'Remove audio source' ); ?></button>
1063                                 </label>
1064                                 <# } #>
1065                                 <?php endforeach ?>
1066
1067                                 <# if ( ! _.isEmpty( html5types ) ) { #>
1068                                 <div class="setting">
1069                                         <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ) ?></span>
1070                                         <div class="button-large">
1071                                         <# _.each( html5types, function (mime, type) { #>
1072                                         <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button>
1073                                         <# } ) #>
1074                                         </div>
1075                                 </div>
1076                                 <# } #>
1077
1078                                 <div class="setting preload">
1079                                         <span><?php _e( 'Preload' ); ?></span>
1080                                         <div class="button-group button-large" data-setting="preload">
1081                                                 <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button>
1082                                                 <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button>
1083                                                 <button class="button active" value="none"><?php _e( 'None' ); ?></button>
1084                                         </div>
1085                                 </div>
1086
1087                                 <label class="setting checkbox-setting">
1088                                         <input type="checkbox" data-setting="autoplay" />
1089                                         <span><?php _e( 'Autoplay' ); ?></span>
1090                                 </label>
1091
1092                                 <label class="setting checkbox-setting">
1093                                         <input type="checkbox" data-setting="loop" />
1094                                         <span><?php _e( 'Loop' ); ?></span>
1095                                 </label>
1096                         </div>
1097                 </div>
1098         </script>
1099
1100         <script type="text/html" id="tmpl-video-details">
1101                 <# var ext, html5types = {
1102                         mp4: wp.media.view.settings.embedMimes.mp4,
1103                         ogv: wp.media.view.settings.embedMimes.ogv,
1104                         webm: wp.media.view.settings.embedMimes.webm
1105                 }; #>
1106
1107                 <?php $video_types = wp_get_video_extensions(); ?>
1108                 <div class="media-embed media-embed-details">
1109                         <div class="embed-media-settings embed-video-settings">
1110                                 <div class="wp-video-holder">
1111                                 <#
1112                                 var w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width,
1113                                         h = ! data.model.height ? 360 : data.model.height;
1114
1115                                 if ( data.model.width && w !== data.model.width ) {
1116                                         h = Math.ceil( ( h * w ) / data.model.width );
1117                                 }
1118                                 #>
1119
1120                                 <?php wp_underscore_video_template() ?>
1121
1122                                 <# if ( ! _.isEmpty( data.model.src ) ) {
1123                                         ext = data.model.src.split('.').pop();
1124                                         if ( html5types[ ext ] ) {
1125                                                 delete html5types[ ext ];
1126                                         }
1127                                 #>
1128                                 <label class="setting">
1129                                         <span>SRC</span>
1130                                         <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" />
1131                                         <button type="button" class="button-link remove-setting"><?php _e( 'Remove video source' ); ?></button>
1132                                 </label>
1133                                 <# } #>
1134                                 <?php foreach ( $video_types as $type ):
1135                                 ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) {
1136                                         if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) {
1137                                                 delete html5types.<?php echo $type ?>;
1138                                         }
1139                                 #>
1140                                 <label class="setting">
1141                                         <span><?php echo strtoupper( $type ) ?></span>
1142                                         <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" />
1143                                         <button type="button" class="button-link remove-setting"><?php _e( 'Remove video source' ); ?></button>
1144                                 </label>
1145                                 <# } #>
1146                                 <?php endforeach ?>
1147                                 </div>
1148
1149                                 <# if ( ! _.isEmpty( html5types ) ) { #>
1150                                 <div class="setting">
1151                                         <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ); ?></span>
1152                                         <div class="button-large">
1153                                         <# _.each( html5types, function (mime, type) { #>
1154                                         <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button>
1155                                         <# } ) #>
1156                                         </div>
1157                                 </div>
1158                                 <# } #>
1159
1160                                 <# if ( ! _.isEmpty( data.model.poster ) ) { #>
1161                                 <label class="setting">
1162                                         <span><?php _e( 'Poster Image' ); ?></span>
1163                                         <input type="text" disabled="disabled" data-setting="poster" value="{{ data.model.poster }}" />
1164                                         <button type="button" class="button-link remove-setting"><?php _e( 'Remove poster image' ); ?></button>
1165                                 </label>
1166                                 <# } #>
1167                                 <div class="setting preload">
1168                                         <span><?php _e( 'Preload' ); ?></span>
1169                                         <div class="button-group button-large" data-setting="preload">
1170                                                 <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button>
1171                                                 <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button>
1172                                                 <button class="button active" value="none"><?php _e( 'None' ); ?></button>
1173                                         </div>
1174                                 </div>
1175
1176                                 <label class="setting checkbox-setting">
1177                                         <input type="checkbox" data-setting="autoplay" />
1178                                         <span><?php _e( 'Autoplay' ); ?></span>
1179                                 </label>
1180
1181                                 <label class="setting checkbox-setting">
1182                                         <input type="checkbox" data-setting="loop" />
1183                                         <span><?php _e( 'Loop' ); ?></span>
1184                                 </label>
1185
1186                                 <label class="setting" data-setting="content">
1187                                         <span><?php _e( 'Tracks (subtitles, captions, descriptions, chapters, or metadata)' ); ?></span>
1188                                         <#
1189                                         var content = '';
1190                                         if ( ! _.isEmpty( data.model.content ) ) {
1191                                                 var tracks = jQuery( data.model.content ).filter( 'track' );
1192                                                 _.each( tracks.toArray(), function (track) {
1193                                                         content += track.outerHTML; #>
1194                                                 <p>
1195                                                         <input class="content-track" type="text" value="{{ track.outerHTML }}" />
1196                                                         <button type="button" class="button-link remove-setting remove-track"><?php _ex( 'Remove video track', 'media' ); ?></button>
1197                                                 </p>
1198                                                 <# } ); #>
1199                                         <# } else { #>
1200                                         <em><?php _e( 'There are no associated subtitles.' ); ?></em>
1201                                         <# } #>
1202                                         <textarea class="hidden content-setting">{{ content }}</textarea>
1203                                 </label>
1204                         </div>
1205                 </div>
1206         </script>
1207
1208         <script type="text/html" id="tmpl-editor-gallery">
1209                 <# if ( data.attachments.length ) { #>
1210                         <div class="gallery gallery-columns-{{ data.columns }}">
1211                                 <# _.each( data.attachments, function( attachment, index ) { #>
1212                                         <dl class="gallery-item">
1213                                                 <dt class="gallery-icon">
1214                                                         <# if ( attachment.thumbnail ) { #>
1215                                                                 <img src="{{ attachment.thumbnail.url }}" width="{{ attachment.thumbnail.width }}" height="{{ attachment.thumbnail.height }}" alt="" />
1216                                                         <# } else { #>
1217                                                                 <img src="{{ attachment.url }}" alt="" />
1218                                                         <# } #>
1219                                                 </dt>
1220                                                 <# if ( attachment.caption ) { #>
1221                                                         <dd class="wp-caption-text gallery-caption">
1222                                                                 {{{ data.verifyHTML( attachment.caption ) }}}
1223                                                         </dd>
1224                                                 <# } #>
1225                                         </dl>
1226                                         <# if ( index % data.columns === data.columns - 1 ) { #>
1227                                                 <br style="clear: both;">
1228                                         <# } #>
1229                                 <# } ); #>
1230                         </div>
1231                 <# } else { #>
1232                         <div class="wpview-error">
1233                                 <div class="dashicons dashicons-format-gallery"></div><p><?php _e( 'No items found.' ); ?></p>
1234                         </div>
1235                 <# } #>
1236         </script>
1237
1238         <script type="text/html" id="tmpl-crop-content">
1239                 <img class="crop-image" src="{{ data.url }}" alt="<?php esc_attr_e( 'Image crop area preview. Requires mouse interaction.' ); ?>">
1240                 <div class="upload-errors"></div>
1241         </script>
1242
1243         <script type="text/html" id="tmpl-site-icon-preview">
1244                 <h2><?php _e( 'Preview' ); ?></h2>
1245                 <strong aria-hidden="true"><?php _e( 'As a browser icon' ); ?></strong>
1246                 <div class="favicon-preview">
1247                         <img src="<?php echo esc_url( admin_url( 'images/' . ( is_rtl() ? 'browser-rtl.png' : 'browser.png' ) ) ); ?>" class="browser-preview" width="182" height="" alt="" />
1248
1249                         <div class="favicon">
1250                                 <img id="preview-favicon" src="{{ data.url }}" alt="<?php esc_attr_e( 'Preview as a browser icon' ); ?>"/>
1251                         </div>
1252                         <span class="browser-title" aria-hidden="true"><?php bloginfo( 'name' ); ?></span>
1253                 </div>
1254
1255                 <strong aria-hidden="true"><?php _e( 'As an app icon' ); ?></strong>
1256                 <div class="app-icon-preview">
1257                         <img id="preview-app-icon" src="{{ data.url }}" alt="<?php esc_attr_e( 'Preview as an app icon' ); ?>"/>
1258                 </div>
1259         </script>
1260
1261         <?php
1262
1263         /**
1264          * Fires when the custom Backbone media templates are printed.
1265          *
1266          * @since 3.5.0
1267          */
1268         do_action( 'print_media_templates' );
1269 }