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.'), 'https://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 _ex( 'Trash', 'verb' ); ?></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 _ex( 'Trash', 'verb' ); ?></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 Selection' ); ?></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" />
738 <label class="setting size">
739 <span><?php _e( 'Size' ); ?></span>
740 <select class="size" name="size"
742 <# if ( data.userSettings ) { #>
743 data-user-setting="imgsize"
747 // This filter is documented in wp-admin/includes/media.php
748 $size_names = apply_filters( 'image_size_names_choose', array(
749 'thumbnail' => __( 'Thumbnail' ),
750 'medium' => __( 'Medium' ),
751 'large' => __( 'Large' ),
752 'full' => __( 'Full Size' ),
755 foreach ( $size_names as $size => $label ) : ?>
756 <option value="<?php echo esc_attr( $size ); ?>">
757 <?php echo esc_html( $label ); ?>
764 <script type="text/html" id="tmpl-playlist-settings">
765 <h3><?php _e( 'Playlist Settings' ); ?></h3>
767 <# var emptyModel = _.isEmpty( data.model ),
768 isVideo = 'video' === data.controller.get('library').props.get('type'); #>
770 <label class="setting">
771 <input type="checkbox" data-setting="tracklist" <# if ( emptyModel ) { #>
774 <# if ( isVideo ) { #>
775 <span><?php _e( 'Show Video List' ); ?></span>
777 <span><?php _e( 'Show Tracklist' ); ?></span>
781 <# if ( ! isVideo ) { #>
782 <label class="setting">
783 <input type="checkbox" data-setting="artists" <# if ( emptyModel ) { #>
786 <span><?php _e( 'Show Artist Name in Tracklist' ); ?></span>
790 <label class="setting">
791 <input type="checkbox" data-setting="images" <# if ( emptyModel ) { #>
794 <span><?php _e( 'Show Images' ); ?></span>
798 <script type="text/html" id="tmpl-embed-link-settings">
799 <label class="setting title">
800 <span><?php _e( 'Title' ); ?></span>
801 <input type="text" class="alignment" data-setting="title" />
803 <div class="embed-container" style="display: none;">
804 <div class="embed-preview"></div>
808 <script type="text/html" id="tmpl-embed-image-settings">
809 <div class="thumbnail">
810 <img src="{{ data.model.url }}" draggable="false" />
814 /** This filter is documented in wp-admin/includes/media.php */
815 if ( ! apply_filters( 'disable_captions', '' ) ) : ?>
816 <label class="setting caption">
817 <span><?php _e('Caption'); ?></span>
818 <textarea data-setting="caption" />
822 <label class="setting alt-text">
823 <span><?php _e('Alt Text'); ?></span>
824 <input type="text" data-setting="alt" />
827 <div class="setting align">
828 <span><?php _e('Align'); ?></span>
829 <div class="button-group button-large" data-setting="align">
830 <button class="button" value="left">
831 <?php esc_attr_e('Left'); ?>
833 <button class="button" value="center">
834 <?php esc_attr_e('Center'); ?>
836 <button class="button" value="right">
837 <?php esc_attr_e('Right'); ?>
839 <button class="button active" value="none">
840 <?php esc_attr_e('None'); ?>
845 <div class="setting link-to">
846 <span><?php _e('Link To'); ?></span>
847 <div class="button-group button-large" data-setting="link">
848 <button class="button" value="file">
849 <?php esc_attr_e('Image URL'); ?>
851 <button class="button" value="custom">
852 <?php esc_attr_e('Custom URL'); ?>
854 <button class="button active" value="none">
855 <?php esc_attr_e('None'); ?>
858 <input type="text" class="link-to-custom" data-setting="linkUrl" />
862 <script type="text/html" id="tmpl-image-details">
863 <div class="media-embed">
864 <div class="embed-media-settings">
865 <div class="column-image">
867 <img src="{{ data.model.url }}" draggable="false" />
869 <# if ( data.attachment && window.imageEdit ) { #>
870 <div class="actions">
871 <input type="button" class="edit-attachment button" value="<?php esc_attr_e( 'Edit Original' ); ?>" />
872 <input type="button" class="replace-attachment button" value="<?php esc_attr_e( 'Replace' ); ?>" />
877 <div class="column-settings">
879 /** This filter is documented in wp-admin/includes/media.php */
880 if ( ! apply_filters( 'disable_captions', '' ) ) : ?>
881 <label class="setting caption">
882 <span><?php _e('Caption'); ?></span>
883 <textarea data-setting="caption">{{ data.model.caption }}</textarea>
887 <label class="setting alt-text">
888 <span><?php _e('Alternative Text'); ?></span>
889 <input type="text" data-setting="alt" value="{{ data.model.alt }}" />
892 <h3><?php _e( 'Display Settings' ); ?></h3>
893 <div class="setting align">
894 <span><?php _e('Align'); ?></span>
895 <div class="button-group button-large" data-setting="align">
896 <button class="button" value="left">
897 <?php esc_attr_e('Left'); ?>
899 <button class="button" value="center">
900 <?php esc_attr_e('Center'); ?>
902 <button class="button" value="right">
903 <?php esc_attr_e('Right'); ?>
905 <button class="button active" value="none">
906 <?php esc_attr_e('None'); ?>
911 <# if ( data.attachment ) { #>
912 <# if ( 'undefined' !== typeof data.attachment.sizes ) { #>
913 <label class="setting size">
914 <span><?php _e('Size'); ?></span>
915 <select class="size" name="size"
917 <# if ( data.userSettings ) { #>
918 data-user-setting="imgsize"
921 /** This filter is documented in wp-admin/includes/media.php */
922 $sizes = apply_filters( 'image_size_names_choose', array(
923 'thumbnail' => __('Thumbnail'),
924 'medium' => __('Medium'),
925 'large' => __('Large'),
926 'full' => __('Full Size'),
929 foreach ( $sizes as $value => $name ) : ?>
931 var size = data.sizes['<?php echo esc_js( $value ); ?>'];
933 <option value="<?php echo esc_attr( $value ); ?>">
934 <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }}
938 <option value="<?php echo esc_attr( 'custom' ); ?>">
939 <?php _e( 'Custom Size' ); ?>
944 <div class="custom-size<# if ( data.model.size !== 'custom' ) { #> hidden<# } #>">
945 <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>
949 <div class="setting link-to">
950 <span><?php _e('Link To'); ?></span>
951 <select data-setting="link">
952 <# if ( data.attachment ) { #>
953 <option value="file">
954 <?php esc_attr_e('Media File'); ?>
956 <option value="post">
957 <?php esc_attr_e('Attachment Page'); ?>
960 <option value="file">
961 <?php esc_attr_e('Image URL'); ?>
964 <option value="custom">
965 <?php esc_attr_e('Custom URL'); ?>
967 <option value="none">
968 <?php esc_attr_e('None'); ?>
971 <input type="text" class="link-to-custom" data-setting="linkUrl" />
973 <div class="advanced-section">
974 <h3><a class="advanced-toggle" href="#"><?php _e('Advanced Options'); ?></a></h3>
975 <div class="advanced-settings hidden">
976 <div class="advanced-image">
977 <label class="setting title-text">
978 <span><?php _e('Image Title Attribute'); ?></span>
979 <input type="text" data-setting="title" value="{{ data.model.title }}" />
981 <label class="setting extra-classes">
982 <span><?php _e('Image CSS Class'); ?></span>
983 <input type="text" data-setting="extraClasses" value="{{ data.model.extraClasses }}" />
986 <div class="advanced-link">
987 <div class="setting link-target">
988 <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>
990 <label class="setting link-rel">
991 <span><?php _e('Link Rel'); ?></span>
992 <input type="text" data-setting="linkRel" value="{{ data.model.linkClassName }}" />
994 <label class="setting link-class-name">
995 <span><?php _e('Link CSS Class'); ?></span>
996 <input type="text" data-setting="linkClassName" value="{{ data.model.linkClassName }}" />
1006 <script type="text/html" id="tmpl-image-editor">
1007 <div id="media-head-{{ data.id }}"></div>
1008 <div id="image-editor-{{ data.id }}"></div>
1011 <script type="text/html" id="tmpl-audio-details">
1012 <# var ext, html5types = {
1013 mp3: wp.media.view.settings.embedMimes.mp3,
1014 ogg: wp.media.view.settings.embedMimes.ogg
1017 <?php $audio_types = wp_get_audio_extensions(); ?>
1018 <div class="media-embed media-embed-details">
1019 <div class="embed-media-settings embed-audio-settings">
1020 <?php wp_underscore_audio_template() ?>
1022 <# if ( ! _.isEmpty( data.model.src ) ) {
1023 ext = data.model.src.split('.').pop();
1024 if ( html5types[ ext ] ) {
1025 delete html5types[ ext ];
1028 <label class="setting">
1030 <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" />
1031 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1036 foreach ( $audio_types as $type ):
1037 ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) {
1038 if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) {
1039 delete html5types.<?php echo $type ?>;
1042 <label class="setting">
1043 <span><?php echo strtoupper( $type ) ?></span>
1044 <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" />
1045 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1050 <# if ( ! _.isEmpty( html5types ) ) { #>
1051 <div class="setting">
1052 <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ) ?></span>
1053 <div class="button-large">
1054 <# _.each( html5types, function (mime, type) { #>
1055 <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button>
1061 <div class="setting preload">
1062 <span><?php _e( 'Preload' ); ?></span>
1063 <div class="button-group button-large" data-setting="preload">
1064 <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button>
1065 <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button>
1066 <button class="button active" value="none"><?php _e( 'None' ); ?></button>
1070 <label class="setting checkbox-setting">
1071 <input type="checkbox" data-setting="autoplay" />
1072 <span><?php _e( 'Autoplay' ); ?></span>
1075 <label class="setting checkbox-setting">
1076 <input type="checkbox" data-setting="loop" />
1077 <span><?php _e( 'Loop' ); ?></span>
1083 <script type="text/html" id="tmpl-video-details">
1084 <# var ext, html5types = {
1085 mp4: wp.media.view.settings.embedMimes.mp4,
1086 ogv: wp.media.view.settings.embedMimes.ogv,
1087 webm: wp.media.view.settings.embedMimes.webm
1090 <?php $video_types = wp_get_video_extensions(); ?>
1091 <div class="media-embed media-embed-details">
1092 <div class="embed-media-settings embed-video-settings">
1093 <div class="wp-video-holder">
1095 var isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/);
1096 w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width,
1097 h = ! data.model.height ? 360 : data.model.height;
1099 if ( data.model.width && w !== data.model.width ) {
1100 h = Math.ceil( ( h * w ) / data.model.width );
1104 <?php wp_underscore_video_template() ?>
1106 <# if ( ! _.isEmpty( data.model.src ) ) {
1107 ext = data.model.src.split('.').pop();
1108 if ( html5types[ ext ] ) {
1109 delete html5types[ ext ];
1112 <label class="setting">
1114 <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" />
1115 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1118 <?php foreach ( $video_types as $type ):
1119 ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) {
1120 if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) {
1121 delete html5types.<?php echo $type ?>;
1124 <label class="setting">
1125 <span><?php echo strtoupper( $type ) ?></span>
1126 <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" />
1127 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1133 <# if ( ! _.isEmpty( html5types ) ) { #>
1134 <div class="setting">
1135 <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ); ?></span>
1136 <div class="button-large">
1137 <# _.each( html5types, function (mime, type) { #>
1138 <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button>
1144 <# if ( ! _.isEmpty( data.model.poster ) ) { #>
1145 <label class="setting">
1146 <span><?php _e( 'Poster Image' ); ?></span>
1147 <input type="text" disabled="disabled" data-setting="poster" value="{{ data.model.poster }}" />
1148 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1151 <div class="setting preload">
1152 <span><?php _e( 'Preload' ); ?></span>
1153 <div class="button-group button-large" data-setting="preload">
1154 <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button>
1155 <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button>
1156 <button class="button active" value="none"><?php _e( 'None' ); ?></button>
1160 <label class="setting checkbox-setting">
1161 <input type="checkbox" data-setting="autoplay" />
1162 <span><?php _e( 'Autoplay' ); ?></span>
1165 <label class="setting checkbox-setting">
1166 <input type="checkbox" data-setting="loop" />
1167 <span><?php _e( 'Loop' ); ?></span>
1170 <label class="setting" data-setting="content">
1171 <span><?php _e( 'Tracks (subtitles, captions, descriptions, chapters, or metadata)' ); ?></span>
1174 if ( ! _.isEmpty( data.model.content ) ) {
1175 var tracks = jQuery( data.model.content ).filter( 'track' );
1176 _.each( tracks.toArray(), function (track) {
1177 content += track.outerHTML; #>
1179 <input class="content-track" type="text" value="{{ track.outerHTML }}" />
1180 <a class="remove-setting remove-track"><?php _e( 'Remove' ); ?></a>
1184 <em><?php _e( 'There are no associated subtitles.' ); ?></em>
1186 <textarea class="hidden content-setting">{{ content }}</textarea>
1192 <script type="text/html" id="tmpl-editor-gallery">
1193 <# if ( data.attachments ) { #>
1194 <div class="gallery gallery-columns-{{ data.columns }}">
1195 <# _.each( data.attachments, function( attachment, index ) { #>
1196 <dl class="gallery-item">
1197 <dt class="gallery-icon">
1198 <# if ( attachment.thumbnail ) { #>
1199 <img src="{{ attachment.thumbnail.url }}" width="{{ attachment.thumbnail.width }}" height="{{ attachment.thumbnail.height }}" />
1201 <img src="{{ attachment.url }}" />
1204 <# if ( attachment.caption ) { #>
1205 <dd class="wp-caption-text gallery-caption">
1206 {{ attachment.caption }}
1210 <# if ( index % data.columns === data.columns - 1 ) { #>
1211 <br style="clear: both;">
1216 <div class="wpview-error">
1217 <div class="dashicons dashicons-format-gallery"></div><p><?php _e( 'No items found.' ); ?></p>
1222 <script type="text/html" id="tmpl-crop-content">
1223 <img class="crop-image" src="{{ data.url }}">
1224 <div class="upload-errors"></div>
1230 * Fires when the custom Backbone media templates are printed.
1234 do_action( 'print_media_templates' );