3 * WordPress media templates.
11 * Output the markup for a audio tag to be used in an Underscore template
12 * when data.model is passed.
16 function wp_underscore_audio_template() {
17 $audio_types = wp_get_audio_extensions();
19 <audio style="visibility: hidden"
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 }}"
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 ?><#
31 <# if ( ! _.isEmpty( data.model.src ) ) { #>
32 <source src="{{ data.model.src }}" type="{{ wp.media.view.settings.embedMimes[ data.model.src.split('.').pop() ] }}" />
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 ?>' ] }}" />
45 * Output the markup for a video tag to be used in an Underscore template
46 * when data.model is passed.
50 function wp_underscore_video_template() {
51 $video_types = wp_get_video_extensions();
53 <# var w_rule = h_rule = '',
54 w, h, settings = wp.media.view.settings,
55 isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/);
57 if ( settings.contentWidth && data.model.width >= settings.contentWidth ) {
58 w = settings.contentWidth;
63 if ( w !== data.model.width ) {
64 h = Math.ceil( ( data.model.height * w ) / data.model.width );
66 h = data.model.height;
70 w_rule = 'width: ' + w + 'px; ';
73 h_rule = 'height: ' + h + 'px;';
76 <div style="{{ w_rule }}{{ h_rule }}" class="wp-video">
78 class="wp-video-shortcode{{ isYouTube ? ' youtube-video' : '' }}"
79 <# if ( w ) { #>width="{{ w }}"<# } #>
80 <# if ( h ) { #>height="{{ h }}"<# } #>
82 $props = array( 'poster' => '', 'preload' => 'metadata' );
83 foreach ( $props as $key => $value ):
84 if ( empty( $value ) ) {
86 if ( ! _.isUndefined( data.model.<?php echo $key ?> ) && data.model.<?php echo $key ?> ) {
87 #> <?php echo $key ?>="{{ data.model.<?php echo $key ?> }}"<#
90 echo $key ?>="{{ _.isUndefined( data.model.<?php echo $key ?> ) ? '<?php echo $value ?>' : data.model.<?php echo $key ?> }}"<?php
94 <?php foreach ( array( 'autoplay', 'loop' ) as $attr ):
95 ?> if ( ! _.isUndefined( data.model.<?php echo $attr ?> ) && data.model.<?php echo $attr ?> ) {
96 #> <?php echo $attr ?><#
100 <# if ( ! _.isEmpty( data.model.src ) ) {
101 if ( isYouTube ) { #>
102 <source src="{{ data.model.src }}" type="video/youtube" />
104 <source src="{{ data.model.src }}" type="{{ settings.embedMimes[ data.model.src.split('.').pop() ] }}" />
108 <?php foreach ( $video_types as $type ):
109 ?><# if ( data.model.<?php echo $type ?> ) { #>
110 <source src="{{ data.model.<?php echo $type ?> }}" type="{{ settings.embedMimes[ '<?php echo $type ?>' ] }}" />
113 {{{ data.model.content }}}
120 * Prints the templates used in the media manager.
124 function wp_print_media_templates() {
126 $class = 'media-modal wp-core-ui';
127 if ( $is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false )
133 outline: #1e8cbe solid;
135 .selected.attachment {
136 outline: #1e8cbe solid;
140 <script type="text/html" id="tmpl-media-frame">
141 <div class="media-frame-menu"></div>
142 <div class="media-frame-title"></div>
143 <div class="media-frame-router"></div>
144 <div class="media-frame-content"></div>
145 <div class="media-frame-toolbar"></div>
146 <div class="media-frame-uploader"></div>
149 <script type="text/html" id="tmpl-media-modal">
150 <div class="<?php echo $class; ?>">
151 <a class="media-modal-close" href="#"><span class="media-modal-icon"><span class="screen-reader-text"><?php _e( 'Close media panel' ); ?></span></span></a>
152 <div class="media-modal-content"></div>
154 <div class="media-modal-backdrop"></div>
157 <script type="text/html" id="tmpl-uploader-window">
158 <div class="uploader-window-content">
159 <h3><?php _e( 'Drop files to upload' ); ?></h3>
163 <script type="text/html" id="tmpl-uploader-editor">
164 <div class="uploader-editor-content">
165 <div class="uploader-editor-title"><?php _e( 'Drop files to upload' ); ?></div>
169 <script type="text/html" id="tmpl-uploader-inline">
170 <# var messageClass = data.message ? 'has-upload-message' : 'no-upload-message'; #>
171 <# if ( data.canClose ) { #>
172 <button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close uploader' ); ?></span></button>
174 <div class="uploader-inline-content {{ messageClass }}">
175 <# if ( data.message ) { #>
176 <h3 class="upload-message">{{ data.message }}</h3>
178 <?php if ( ! _device_can_upload() ) : ?>
179 <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.'), 'http://apps.wordpress.org/' ); ?></h3>
180 <?php elseif ( is_multisite() && ! is_upload_space_available() ) : ?>
181 <h3 class="upload-instructions"><?php _e( 'Upload Limit Exceeded' ); ?></h3>
183 /** This action is documented in wp-admin/includes/media.php */
184 do_action( 'upload_ui_over_quota' ); ?>
187 <div class="upload-ui">
188 <h3 class="upload-instructions drop-instructions"><?php _e( 'Drop files anywhere to upload' ); ?></h3>
189 <p class="upload-instructions drop-instructions"><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p>
190 <a href="#" class="browser button button-hero"><?php _e( 'Select Files' ); ?></a>
193 <div class="upload-inline-status"></div>
195 <div class="post-upload-ui">
197 /** This action is documented in wp-admin/includes/media.php */
198 do_action( 'pre-upload-ui' );
199 /** This action is documented in wp-admin/includes/media.php */
200 do_action( 'pre-plupload-upload-ui' );
202 if ( 10 === remove_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ) ) {
203 /** This action is documented in wp-admin/includes/media.php */
204 do_action( 'post-plupload-upload-ui' );
205 add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' );
207 /** This action is documented in wp-admin/includes/media.php */
208 do_action( 'post-plupload-upload-ui' );
211 $max_upload_size = wp_max_upload_size();
212 if ( ! $max_upload_size ) {
213 $max_upload_size = 0;
217 <p class="max-upload-size"><?php
218 printf( __( 'Maximum upload file size: %s.' ), esc_html( size_format( $max_upload_size ) ) );
221 <# if ( data.suggestedWidth && data.suggestedHeight ) { #>
222 <p class="suggested-dimensions">
223 <?php _e( 'Suggested image dimensions:' ); ?> {{data.suggestedWidth}} × {{data.suggestedHeight}}
228 /** This action is documented in wp-admin/includes/media.php */
229 do_action( 'post-upload-ui' ); ?>
235 <script type="text/html" id="tmpl-media-library-view-switcher">
236 <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-list">
237 <span class="screen-reader-text"><?php _e( 'List View' ); ?></span>
239 <a href="<?php echo esc_url( add_query_arg( 'mode', 'grid', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-grid current">
240 <span class="screen-reader-text"><?php _e( 'Grid View' ); ?></span>
244 <script type="text/html" id="tmpl-uploader-status">
245 <h3><?php _e( 'Uploading' ); ?></h3>
246 <a class="upload-dismiss-errors" href="#"><?php _e('Dismiss Errors'); ?></a>
248 <div class="media-progress-bar"><div></div></div>
249 <div class="upload-details">
250 <span class="upload-count">
251 <span class="upload-index"></span> / <span class="upload-total"></span>
253 <span class="upload-detail-separator">–</span>
254 <span class="upload-filename"></span>
256 <div class="upload-errors"></div>
259 <script type="text/html" id="tmpl-uploader-status-error">
260 <span class="upload-error-label"><?php _e('Error'); ?></span>
261 <span class="upload-error-filename">{{{ data.filename }}}</span>
262 <span class="upload-error-message">{{ data.message }}</span>
265 <script type="text/html" id="tmpl-edit-attachment-frame">
266 <div class="edit-media-header">
267 <button class="left dashicons <# if ( ! data.hasPrevious ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit previous media item' ); ?></span></button>
268 <button class="right dashicons <# if ( ! data.hasNext ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit next media item' ); ?></span></button>
270 <div class="media-frame-title"></div>
271 <div class="media-frame-content"></div>
274 <script type="text/html" id="tmpl-attachment-details-two-column">
275 <div class="attachment-media-view {{ data.orientation }}">
276 <div class="thumbnail thumbnail-{{ data.type }}">
277 <# if ( data.uploading ) { #>
278 <div class="media-progress-bar"><div></div></div>
279 <# } else if ( 'image' === data.type && data.sizes && data.sizes.large ) { #>
280 <img class="details-image" src="{{ data.sizes.large.url }}" draggable="false" />
281 <# } else if ( 'image' === data.type && data.sizes && data.sizes.full ) { #>
282 <img class="details-image" src="{{ data.sizes.full.url }}" draggable="false" />
283 <# } else if ( -1 === jQuery.inArray( data.type, [ 'audio', 'video' ] ) ) { #>
284 <img class="details-image" src="{{ data.icon }}" class="icon" draggable="false" />
287 <# if ( 'audio' === data.type ) { #>
288 <div class="wp-media-wrapper">
289 <audio style="visibility: hidden" controls class="wp-audio-shortcode" width="100%" preload="none">
290 <source type="{{ data.mime }}" src="{{ data.url }}"/>
293 <# } else if ( 'video' === data.type ) {
294 var w_rule = h_rule = '';
296 w_rule = 'width: ' + data.width + 'px;';
297 } else if ( wp.media.view.settings.contentWidth ) {
298 w_rule = 'width: ' + wp.media.view.settings.contentWidth + 'px;';
301 h_rule = 'height: ' + data.height + 'px;';
304 <div style="{{ w_rule }}{{ h_rule }}" class="wp-media-wrapper wp-video">
305 <video controls="controls" class="wp-video-shortcode" preload="metadata"
306 <# if ( data.width ) { #>width="{{ data.width }}"<# } #>
307 <# if ( data.height ) { #>height="{{ data.height }}"<# } #>
308 <# if ( data.image && data.image.src !== data.icon ) { #>poster="{{ data.image.src }}"<# } #>>
309 <source type="{{ data.mime }}" src="{{ data.url }}"/>
314 <div class="attachment-actions">
315 <# if ( 'image' === data.type && ! data.uploading && data.sizes && data.can.save ) { #>
316 <a class="button edit-attachment" href="#"><?php _e( 'Edit Image' ); ?></a>
321 <div class="attachment-info">
322 <span class="settings-save-status">
323 <span class="spinner"></span>
324 <span class="saved"><?php esc_html_e('Saved.'); ?></span>
326 <div class="details">
327 <div class="filename"><strong><?php _e( 'File name:' ); ?></strong> {{ data.filename }}</div>
328 <div class="filename"><strong><?php _e( 'File type:' ); ?></strong> {{ data.mime }}</div>
329 <div class="uploaded"><strong><?php _e( 'Uploaded on:' ); ?></strong> {{ data.dateFormatted }}</div>
331 <div class="file-size"><strong><?php _e( 'File size:' ); ?></strong> {{ data.filesizeHumanReadable }}</div>
332 <# if ( 'image' === data.type && ! data.uploading ) { #>
333 <# if ( data.width && data.height ) { #>
334 <div class="dimensions"><strong><?php _e( 'Dimensions:' ); ?></strong> {{ data.width }} × {{ data.height }}</div>
338 <# if ( data.fileLength ) { #>
339 <div class="file-length"><strong><?php _e( 'Length:' ); ?></strong> {{ data.fileLength }}</div>
342 <# if ( 'audio' === data.type && data.meta.bitrate ) { #>
343 <div class="bitrate">
344 <strong><?php _e( 'Bitrate:' ); ?></strong> {{ Math.round( data.meta.bitrate / 1000 ) }}kb/s
345 <# if ( data.meta.bitrate_mode ) { #>
346 {{ ' ' + data.meta.bitrate_mode.toUpperCase() }}
351 <div class="compat-meta">
352 <# if ( data.compat && data.compat.meta ) { #>
353 {{{ data.compat.meta }}}
358 <div class="settings">
359 <label class="setting" data-setting="url">
360 <span class="name"><?php _e('URL'); ?></span>
361 <input type="text" value="{{ data.url }}" readonly />
363 <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #>
364 <label class="setting" data-setting="title">
365 <span class="name"><?php _e('Title'); ?></span>
366 <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} />
368 <# if ( 'audio' === data.type ) { #>
369 <?php foreach ( array(
370 'artist' => __( 'Artist' ),
371 'album' => __( 'Album' ),
372 ) as $key => $label ) : ?>
373 <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>">
374 <span class="name"><?php echo $label ?></span>
375 <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" />
379 <label class="setting" data-setting="caption">
380 <span class="name"><?php _e( 'Caption' ); ?></span>
381 <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea>
383 <# if ( 'image' === data.type ) { #>
384 <label class="setting" data-setting="alt">
385 <span class="name"><?php _e( 'Alt Text' ); ?></span>
386 <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} />
389 <label class="setting" data-setting="description">
390 <span class="name"><?php _e('Description'); ?></span>
391 <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea>
393 <label class="setting">
394 <span class="name"><?php _e( 'Uploaded By' ); ?></span>
395 <span class="value">{{ data.authorName }}</span>
397 <# if ( data.uploadedToTitle ) { #>
398 <label class="setting">
399 <span class="name"><?php _e( 'Uploaded To' ); ?></span>
400 <# if ( data.uploadedToLink ) { #>
401 <span class="value"><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a></span>
403 <span class="value">{{ data.uploadedToTitle }}</span>
407 <div class="attachment-compat"></div>
410 <div class="actions">
411 <a class="view-attachment" href="{{ data.link }}"><?php _e( 'View attachment page' ); ?></a>
412 <# if ( data.can.save ) { #> |
413 <a href="post.php?post={{ data.id }}&action=edit"><?php _e( 'Edit more details' ); ?></a>
415 <# if ( ! data.uploading && data.can.remove ) { #> |
416 <?php if ( MEDIA_TRASH ): ?>
417 <# if ( 'trash' === data.status ) { #>
418 <a class="untrash-attachment" href="#"><?php _e( 'Untrash' ); ?></a>
420 <a class="trash-attachment" href="#"><?php _e( 'Trash' ); ?></a>
423 <a class="delete-attachment" href="#"><?php _e( 'Delete Permanently' ); ?></a>
431 <script type="text/html" id="tmpl-attachment">
432 <div class="attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">
433 <div class="thumbnail">
434 <# if ( data.uploading ) { #>
435 <div class="media-progress-bar"><div style="width: {{ data.percent }}%"></div></div>
436 <# } else if ( 'image' === data.type && data.sizes ) { #>
437 <div class="centered">
438 <img src="{{ data.size.url }}" draggable="false" alt="" />
441 <div class="centered">
442 <# if ( data.image && data.image.src && data.image.src !== data.icon ) { #>
443 <img src="{{ data.image.src }}" class="thumbnail" draggable="false" />
445 <img src="{{ data.icon }}" class="icon" draggable="false" />
448 <div class="filename">
449 <div>{{ data.filename }}</div>
453 <# if ( data.buttons.close ) { #>
454 <a class="close media-modal-icon" href="#" title="<?php esc_attr_e('Remove'); ?>"></a>
457 <# if ( data.buttons.check ) { #>
458 <a class="check" href="#" title="<?php esc_attr_e('Deselect'); ?>" tabindex="-1"><div class="media-modal-icon"></div></a>
461 var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly';
462 if ( data.describe ) {
463 if ( 'image' === data.type ) { #>
464 <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption"
465 placeholder="<?php esc_attr_e('Caption this image…'); ?>" {{ maybeReadOnly }} />
467 <input type="text" value="{{ data.title }}" class="describe" data-setting="title"
468 <# if ( 'video' === data.type ) { #>
469 placeholder="<?php esc_attr_e('Describe this video…'); ?>"
470 <# } else if ( 'audio' === data.type ) { #>
471 placeholder="<?php esc_attr_e('Describe this audio file…'); ?>"
473 placeholder="<?php esc_attr_e('Describe this media file…'); ?>"
474 <# } #> {{ maybeReadOnly }} />
479 <script type="text/html" id="tmpl-attachment-details">
481 <?php _e('Attachment Details'); ?>
483 <span class="settings-save-status">
484 <span class="spinner"></span>
485 <span class="saved"><?php esc_html_e('Saved.'); ?></span>
488 <div class="attachment-info">
489 <div class="thumbnail thumbnail-{{ data.type }}">
490 <# if ( data.uploading ) { #>
491 <div class="media-progress-bar"><div></div></div>
492 <# } else if ( 'image' === data.type && data.sizes ) { #>
493 <img src="{{ data.size.url }}" draggable="false" />
495 <img src="{{ data.icon }}" class="icon" draggable="false" />
498 <div class="details">
499 <div class="filename">{{ data.filename }}</div>
500 <div class="uploaded">{{ data.dateFormatted }}</div>
502 <div class="file-size">{{ data.filesizeHumanReadable }}</div>
503 <# if ( 'image' === data.type && ! data.uploading ) { #>
504 <# if ( data.width && data.height ) { #>
505 <div class="dimensions">{{ data.width }} × {{ data.height }}</div>
508 <# if ( data.can.save && data.sizes ) { #>
509 <a class="edit-attachment" href="{{ data.editLink }}&image-editor" target="_blank"><?php _e( 'Edit Image' ); ?></a>
510 <a class="refresh-attachment" href="#"><?php _e( 'Refresh' ); ?></a>
514 <# if ( data.fileLength ) { #>
515 <div class="file-length"><?php _e( 'Length:' ); ?> {{ data.fileLength }}</div>
518 <# if ( ! data.uploading && data.can.remove ) { #>
519 <?php if ( MEDIA_TRASH ): ?>
520 <# if ( 'trash' === data.status ) { #>
521 <a class="untrash-attachment" href="#"><?php _e( 'Untrash' ); ?></a>
523 <a class="trash-attachment" href="#"><?php _e( 'Trash' ); ?></a>
526 <a class="delete-attachment" href="#"><?php _e( 'Delete Permanently' ); ?></a>
530 <div class="compat-meta">
531 <# if ( data.compat && data.compat.meta ) { #>
532 {{{ data.compat.meta }}}
538 <label class="setting" data-setting="url">
539 <span class="name"><?php _e('URL'); ?></span>
540 <input type="text" value="{{ data.url }}" readonly />
542 <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #>
543 <label class="setting" data-setting="title">
544 <span class="name"><?php _e('Title'); ?></span>
545 <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} />
547 <# if ( 'audio' === data.type ) { #>
548 <?php foreach ( array(
549 'artist' => __( 'Artist' ),
550 'album' => __( 'Album' ),
551 ) as $key => $label ) : ?>
552 <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>">
553 <span class="name"><?php echo $label ?></span>
554 <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" />
558 <label class="setting" data-setting="caption">
559 <span class="name"><?php _e('Caption'); ?></span>
560 <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea>
562 <# if ( 'image' === data.type ) { #>
563 <label class="setting" data-setting="alt">
564 <span class="name"><?php _e('Alt Text'); ?></span>
565 <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} />
568 <label class="setting" data-setting="description">
569 <span class="name"><?php _e('Description'); ?></span>
570 <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea>
574 <script type="text/html" id="tmpl-media-selection">
575 <div class="selection-info">
576 <span class="count"></span>
577 <# if ( data.editable ) { #>
578 <a class="edit-selection" href="#"><?php _e('Edit'); ?></a>
580 <# if ( data.clearable ) { #>
581 <a class="clear-selection" href="#"><?php _e('Clear'); ?></a>
584 <div class="selection-view"></div>
587 <script type="text/html" id="tmpl-attachment-display-settings">
588 <h3><?php _e('Attachment Display Settings'); ?></h3>
590 <# if ( 'image' === data.type ) { #>
591 <label class="setting">
592 <span><?php _e('Alignment'); ?></span>
593 <select class="alignment"
595 <# if ( data.userSettings ) { #>
596 data-user-setting="align"
599 <option value="left">
600 <?php esc_attr_e('Left'); ?>
602 <option value="center">
603 <?php esc_attr_e('Center'); ?>
605 <option value="right">
606 <?php esc_attr_e('Right'); ?>
608 <option value="none" selected>
609 <?php esc_attr_e('None'); ?>
615 <div class="setting">
617 <# if ( data.model.canEmbed ) { #>
618 <span><?php _e('Embed or Link'); ?></span>
620 <span><?php _e('Link To'); ?></span>
623 <select class="link-to"
625 <# if ( data.userSettings && ! data.model.canEmbed ) { #>
626 data-user-setting="urlbutton"
629 <# if ( data.model.canEmbed ) { #>
630 <option value="embed" selected>
631 <?php esc_attr_e('Embed Media Player'); ?>
633 <option value="file">
635 <option value="file" selected>
637 <# if ( data.model.canEmbed ) { #>
638 <?php esc_attr_e('Link to Media File'); ?>
640 <?php esc_attr_e('Media File'); ?>
643 <option value="post">
644 <# if ( data.model.canEmbed ) { #>
645 <?php esc_attr_e('Link to Attachment Page'); ?>
647 <?php esc_attr_e('Attachment Page'); ?>
650 <# if ( 'image' === data.type ) { #>
651 <option value="custom">
652 <?php esc_attr_e('Custom URL'); ?>
654 <option value="none">
655 <?php esc_attr_e('None'); ?>
660 <input type="text" class="link-to-custom" data-setting="linkUrl" />
663 <# if ( 'undefined' !== typeof data.sizes ) { #>
664 <label class="setting">
665 <span><?php _e('Size'); ?></span>
666 <select class="size" name="size"
668 <# if ( data.userSettings ) { #>
669 data-user-setting="imgsize"
672 /** This filter is documented in wp-admin/includes/media.php */
673 $sizes = apply_filters( 'image_size_names_choose', array(
674 'thumbnail' => __('Thumbnail'),
675 'medium' => __('Medium'),
676 'large' => __('Large'),
677 'full' => __('Full Size'),
680 foreach ( $sizes as $value => $name ) : ?>
682 var size = data.sizes['<?php echo esc_js( $value ); ?>'];
684 <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'full' ); ?>>
685 <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }}
694 <script type="text/html" id="tmpl-gallery-settings">
695 <h3><?php _e('Gallery Settings'); ?></h3>
697 <label class="setting">
698 <span><?php _e('Link To'); ?></span>
699 <select class="link-to"
701 <# if ( data.userSettings ) { #>
702 data-user-setting="urlbutton"
705 <option value="post" <# if ( ! wp.media.galleryDefaults.link || 'post' == wp.media.galleryDefaults.link ) {
706 #>selected="selected"<# }
708 <?php esc_attr_e('Attachment Page'); ?>
710 <option value="file" <# if ( 'file' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>>
711 <?php esc_attr_e('Media File'); ?>
713 <option value="none" <# if ( 'none' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>>
714 <?php esc_attr_e('None'); ?>
719 <label class="setting">
720 <span><?php _e('Columns'); ?></span>
721 <select class="columns" name="columns"
722 data-setting="columns">
723 <?php for ( $i = 1; $i <= 9; $i++ ) : ?>
724 <option value="<?php echo esc_attr( $i ); ?>" <#
725 if ( <?php echo $i ?> == wp.media.galleryDefaults.columns ) { #>selected="selected"<# }
727 <?php echo esc_html( $i ); ?>
733 <label class="setting">
734 <span><?php _e( 'Random Order' ); ?></span>
735 <input type="checkbox" data-setting="_orderbyRandom" />
739 <script type="text/html" id="tmpl-playlist-settings">
740 <h3><?php _e( 'Playlist Settings' ); ?></h3>
742 <# var emptyModel = _.isEmpty( data.model ),
743 isVideo = 'video' === data.controller.get('library').props.get('type'); #>
745 <label class="setting">
746 <input type="checkbox" data-setting="tracklist" <# if ( emptyModel ) { #>
749 <# if ( isVideo ) { #>
750 <span><?php _e( 'Show Video List' ); ?></span>
752 <span><?php _e( 'Show Tracklist' ); ?></span>
756 <# if ( ! isVideo ) { #>
757 <label class="setting">
758 <input type="checkbox" data-setting="artists" <# if ( emptyModel ) { #>
761 <span><?php _e( 'Show Artist Name in Tracklist' ); ?></span>
765 <label class="setting">
766 <input type="checkbox" data-setting="images" <# if ( emptyModel ) { #>
769 <span><?php _e( 'Show Images' ); ?></span>
773 <script type="text/html" id="tmpl-embed-link-settings">
774 <label class="setting title">
775 <span><?php _e( 'Title' ); ?></span>
776 <input type="text" class="alignment" data-setting="title" />
778 <div class="embed-container" style="display: none;">
779 <div class="embed-preview"></div>
783 <script type="text/html" id="tmpl-embed-image-settings">
784 <div class="thumbnail">
785 <img src="{{ data.model.url }}" draggable="false" />
789 /** This filter is documented in wp-admin/includes/media.php */
790 if ( ! apply_filters( 'disable_captions', '' ) ) : ?>
791 <label class="setting caption">
792 <span><?php _e('Caption'); ?></span>
793 <textarea data-setting="caption" />
797 <label class="setting alt-text">
798 <span><?php _e('Alt Text'); ?></span>
799 <input type="text" data-setting="alt" />
802 <div class="setting align">
803 <span><?php _e('Align'); ?></span>
804 <div class="button-group button-large" data-setting="align">
805 <button class="button" value="left">
806 <?php esc_attr_e('Left'); ?>
808 <button class="button" value="center">
809 <?php esc_attr_e('Center'); ?>
811 <button class="button" value="right">
812 <?php esc_attr_e('Right'); ?>
814 <button class="button active" value="none">
815 <?php esc_attr_e('None'); ?>
820 <div class="setting link-to">
821 <span><?php _e('Link To'); ?></span>
822 <div class="button-group button-large" data-setting="link">
823 <button class="button" value="file">
824 <?php esc_attr_e('Image URL'); ?>
826 <button class="button" value="custom">
827 <?php esc_attr_e('Custom URL'); ?>
829 <button class="button active" value="none">
830 <?php esc_attr_e('None'); ?>
833 <input type="text" class="link-to-custom" data-setting="linkUrl" />
837 <script type="text/html" id="tmpl-image-details">
838 <div class="media-embed">
839 <div class="embed-media-settings">
840 <div class="column-image">
842 <img src="{{ data.model.url }}" draggable="false" />
844 <# if ( data.attachment && window.imageEdit ) { #>
845 <div class="actions">
846 <input type="button" class="edit-attachment button" value="<?php esc_attr_e( 'Edit Original' ); ?>" />
847 <input type="button" class="replace-attachment button" value="<?php esc_attr_e( 'Replace' ); ?>" />
852 <div class="column-settings">
854 /** This filter is documented in wp-admin/includes/media.php */
855 if ( ! apply_filters( 'disable_captions', '' ) ) : ?>
856 <label class="setting caption">
857 <span><?php _e('Caption'); ?></span>
858 <textarea data-setting="caption">{{ data.model.caption }}</textarea>
862 <label class="setting alt-text">
863 <span><?php _e('Alternative Text'); ?></span>
864 <input type="text" data-setting="alt" value="{{ data.model.alt }}" />
867 <h3><?php _e( 'Display Settings' ); ?></h3>
868 <div class="setting align">
869 <span><?php _e('Align'); ?></span>
870 <div class="button-group button-large" data-setting="align">
871 <button class="button" value="left">
872 <?php esc_attr_e('Left'); ?>
874 <button class="button" value="center">
875 <?php esc_attr_e('Center'); ?>
877 <button class="button" value="right">
878 <?php esc_attr_e('Right'); ?>
880 <button class="button active" value="none">
881 <?php esc_attr_e('None'); ?>
886 <# if ( data.attachment ) { #>
887 <# if ( 'undefined' !== typeof data.attachment.sizes ) { #>
888 <label class="setting size">
889 <span><?php _e('Size'); ?></span>
890 <select class="size" name="size"
892 <# if ( data.userSettings ) { #>
893 data-user-setting="imgsize"
896 /** This filter is documented in wp-admin/includes/media.php */
897 $sizes = apply_filters( 'image_size_names_choose', array(
898 'thumbnail' => __('Thumbnail'),
899 'medium' => __('Medium'),
900 'large' => __('Large'),
901 'full' => __('Full Size'),
904 foreach ( $sizes as $value => $name ) : ?>
906 var size = data.sizes['<?php echo esc_js( $value ); ?>'];
908 <option value="<?php echo esc_attr( $value ); ?>">
909 <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }}
913 <option value="<?php echo esc_attr( 'custom' ); ?>">
914 <?php _e( 'Custom Size' ); ?>
919 <div class="custom-size<# if ( data.model.size !== 'custom' ) { #> hidden<# } #>">
920 <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">×</span><label><span><?php _e( 'Height' ); ?> <small>(px)</small></span><input data-setting="customHeight" type="number" step="1" value="{{ data.model.customHeight }}" /></label>
924 <div class="setting link-to">
925 <span><?php _e('Link To'); ?></span>
926 <select data-setting="link">
927 <# if ( data.attachment ) { #>
928 <option value="file">
929 <?php esc_attr_e('Media File'); ?>
931 <option value="post">
932 <?php esc_attr_e('Attachment Page'); ?>
935 <option value="file">
936 <?php esc_attr_e('Image URL'); ?>
939 <option value="custom">
940 <?php esc_attr_e('Custom URL'); ?>
942 <option value="none">
943 <?php esc_attr_e('None'); ?>
946 <input type="text" class="link-to-custom" data-setting="linkUrl" />
948 <div class="advanced-section">
949 <h3><a class="advanced-toggle" href="#"><?php _e('Advanced Options'); ?></a></h3>
950 <div class="advanced-settings hidden">
951 <div class="advanced-image">
952 <label class="setting title-text">
953 <span><?php _e('Image Title Attribute'); ?></span>
954 <input type="text" data-setting="title" value="{{ data.model.title }}" />
956 <label class="setting extra-classes">
957 <span><?php _e('Image CSS Class'); ?></span>
958 <input type="text" data-setting="extraClasses" value="{{ data.model.extraClasses }}" />
961 <div class="advanced-link">
962 <div class="setting link-target">
963 <label><input type="checkbox" data-setting="linkTargetBlank" value="_blank" <# if ( data.model.linkTargetBlank ) { #>checked="checked"<# } #>><?php _e( 'Open link in a new window/tab' ); ?></label>
965 <label class="setting link-rel">
966 <span><?php _e('Link Rel'); ?></span>
967 <input type="text" data-setting="linkRel" value="{{ data.model.linkClassName }}" />
969 <label class="setting link-class-name">
970 <span><?php _e('Link CSS Class'); ?></span>
971 <input type="text" data-setting="linkClassName" value="{{ data.model.linkClassName }}" />
981 <script type="text/html" id="tmpl-image-editor">
982 <div id="media-head-{{ data.id }}"></div>
983 <div id="image-editor-{{ data.id }}"></div>
986 <script type="text/html" id="tmpl-audio-details">
987 <# var ext, html5types = {
988 mp3: wp.media.view.settings.embedMimes.mp3,
989 ogg: wp.media.view.settings.embedMimes.ogg
992 <?php $audio_types = wp_get_audio_extensions(); ?>
993 <div class="media-embed media-embed-details">
994 <div class="embed-media-settings embed-audio-settings">
995 <?php wp_underscore_audio_template() ?>
997 <# if ( ! _.isEmpty( data.model.src ) ) {
998 ext = data.model.src.split('.').pop();
999 if ( html5types[ ext ] ) {
1000 delete html5types[ ext ];
1003 <label class="setting">
1005 <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" />
1006 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1011 foreach ( $audio_types as $type ):
1012 ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) {
1013 if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) {
1014 delete html5types.<?php echo $type ?>;
1017 <label class="setting">
1018 <span><?php echo strtoupper( $type ) ?></span>
1019 <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" />
1020 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1025 <# if ( ! _.isEmpty( html5types ) ) { #>
1026 <div class="setting">
1027 <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ) ?></span>
1028 <div class="button-large">
1029 <# _.each( html5types, function (mime, type) { #>
1030 <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button>
1036 <div class="setting preload">
1037 <span><?php _e( 'Preload' ); ?></span>
1038 <div class="button-group button-large" data-setting="preload">
1039 <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button>
1040 <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button>
1041 <button class="button active" value="none"><?php _e( 'None' ); ?></button>
1045 <label class="setting checkbox-setting">
1046 <input type="checkbox" data-setting="autoplay" />
1047 <span><?php _e( 'Autoplay' ); ?></span>
1050 <label class="setting checkbox-setting">
1051 <input type="checkbox" data-setting="loop" />
1052 <span><?php _e( 'Loop' ); ?></span>
1058 <script type="text/html" id="tmpl-video-details">
1059 <# var ext, html5types = {
1060 mp4: wp.media.view.settings.embedMimes.mp4,
1061 ogv: wp.media.view.settings.embedMimes.ogv,
1062 webm: wp.media.view.settings.embedMimes.webm
1065 <?php $video_types = wp_get_video_extensions(); ?>
1066 <div class="media-embed media-embed-details">
1067 <div class="embed-media-settings embed-video-settings">
1068 <div class="wp-video-holder">
1070 var isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/);
1071 w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width,
1072 h = ! data.model.height ? 360 : data.model.height;
1074 if ( data.model.width && w !== data.model.width ) {
1075 h = Math.ceil( ( h * w ) / data.model.width );
1079 <?php wp_underscore_video_template() ?>
1081 <# if ( ! _.isEmpty( data.model.src ) ) {
1082 ext = data.model.src.split('.').pop();
1083 if ( html5types[ ext ] ) {
1084 delete html5types[ ext ];
1087 <label class="setting">
1089 <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" />
1090 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1093 <?php foreach ( $video_types as $type ):
1094 ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) {
1095 if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) {
1096 delete html5types.<?php echo $type ?>;
1099 <label class="setting">
1100 <span><?php echo strtoupper( $type ) ?></span>
1101 <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" />
1102 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1108 <# if ( ! _.isEmpty( html5types ) ) { #>
1109 <div class="setting">
1110 <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ); ?></span>
1111 <div class="button-large">
1112 <# _.each( html5types, function (mime, type) { #>
1113 <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button>
1119 <# if ( ! _.isEmpty( data.model.poster ) ) { #>
1120 <label class="setting">
1121 <span><?php _e( 'Poster Image' ); ?></span>
1122 <input type="text" disabled="disabled" data-setting="poster" value="{{ data.model.poster }}" />
1123 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1126 <div class="setting preload">
1127 <span><?php _e( 'Preload' ); ?></span>
1128 <div class="button-group button-large" data-setting="preload">
1129 <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button>
1130 <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button>
1131 <button class="button active" value="none"><?php _e( 'None' ); ?></button>
1135 <label class="setting checkbox-setting">
1136 <input type="checkbox" data-setting="autoplay" />
1137 <span><?php _e( 'Autoplay' ); ?></span>
1140 <label class="setting checkbox-setting">
1141 <input type="checkbox" data-setting="loop" />
1142 <span><?php _e( 'Loop' ); ?></span>
1145 <label class="setting" data-setting="content">
1146 <span><?php _e( 'Tracks (subtitles, captions, descriptions, chapters, or metadata)' ); ?></span>
1149 if ( ! _.isEmpty( data.model.content ) ) {
1150 var tracks = jQuery( data.model.content ).filter( 'track' );
1151 _.each( tracks.toArray(), function (track) {
1152 content += track.outerHTML; #>
1154 <input class="content-track" type="text" value="{{ track.outerHTML }}" />
1155 <a class="remove-setting remove-track"><?php _e( 'Remove' ); ?></a>
1159 <em><?php _e( 'There are no associated subtitles.' ); ?></em>
1161 <textarea class="hidden content-setting">{{ content }}</textarea>
1167 <script type="text/html" id="tmpl-editor-gallery">
1168 <# if ( data.attachments ) { #>
1169 <div class="gallery gallery-columns-{{ data.columns }}">
1170 <# _.each( data.attachments, function( attachment, index ) { #>
1171 <dl class="gallery-item">
1172 <dt class="gallery-icon">
1173 <# if ( attachment.thumbnail ) { #>
1174 <img src="{{ attachment.thumbnail.url }}" width="{{ attachment.thumbnail.width }}" height="{{ attachment.thumbnail.height }}" />
1176 <img src="{{ attachment.url }}" />
1179 <# if ( attachment.caption ) { #>
1180 <dd class="wp-caption-text gallery-caption">
1181 {{ attachment.caption }}
1185 <# if ( index % data.columns === data.columns - 1 ) { #>
1186 <br style="clear: both;">
1191 <div class="wpview-error">
1192 <div class="dashicons dashicons-format-gallery"></div><p><?php _e( 'No items found.' ); ?></p>
1197 <script type="text/html" id="tmpl-crop-content">
1198 <img class="crop-image" src="{{ data.url }}">
1199 <div class="upload-errors"></div>
1205 * Fires when the custom Backbone media templates are printed.
1209 do_action( 'print_media_templates' );