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 ) { #>
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.uploadedTo ) { #>
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 <a href="post.php?post={{ data.id }}&action=edit"><?php _e( 'Edit more details' ); ?></a>
413 <# if ( ! data.uploading && data.can.remove ) { #> |
414 <?php if ( MEDIA_TRASH ): ?>
415 <# if ( 'trash' === data.status ) { #>
416 <a class="untrash-attachment" href="#"><?php _e( 'Untrash' ); ?></a>
418 <a class="trash-attachment" href="#"><?php _e( 'Trash' ); ?></a>
421 <a class="delete-attachment" href="#"><?php _e( 'Delete Permanently' ); ?></a>
429 <script type="text/html" id="tmpl-attachment">
430 <div class="attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">
431 <div class="thumbnail">
432 <# if ( data.uploading ) { #>
433 <div class="media-progress-bar"><div style="width: {{ data.percent }}%"></div></div>
434 <# } else if ( 'image' === data.type && data.sizes ) { #>
435 <div class="centered">
436 <img src="{{ data.size.url }}" draggable="false" alt="" />
439 <div class="centered">
440 <# if ( data.image && data.image.src && data.image.src !== data.icon ) { #>
441 <img src="{{ data.image.src }}" class="thumbnail" draggable="false" />
443 <img src="{{ data.icon }}" class="icon" draggable="false" />
446 <div class="filename">
447 <div>{{ data.filename }}</div>
451 <# if ( data.buttons.close ) { #>
452 <a class="close media-modal-icon" href="#" title="<?php esc_attr_e('Remove'); ?>"></a>
455 <# if ( data.buttons.check ) { #>
456 <a class="check" href="#" title="<?php esc_attr_e('Deselect'); ?>" tabindex="-1"><div class="media-modal-icon"></div></a>
459 var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly';
460 if ( data.describe ) {
461 if ( 'image' === data.type ) { #>
462 <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption"
463 placeholder="<?php esc_attr_e('Caption this image…'); ?>" {{ maybeReadOnly }} />
465 <input type="text" value="{{ data.title }}" class="describe" data-setting="title"
466 <# if ( 'video' === data.type ) { #>
467 placeholder="<?php esc_attr_e('Describe this video…'); ?>"
468 <# } else if ( 'audio' === data.type ) { #>
469 placeholder="<?php esc_attr_e('Describe this audio file…'); ?>"
471 placeholder="<?php esc_attr_e('Describe this media file…'); ?>"
472 <# } #> {{ maybeReadOnly }} />
477 <script type="text/html" id="tmpl-attachment-details">
479 <?php _e('Attachment Details'); ?>
481 <span class="settings-save-status">
482 <span class="spinner"></span>
483 <span class="saved"><?php esc_html_e('Saved.'); ?></span>
486 <div class="attachment-info">
487 <div class="thumbnail thumbnail-{{ data.type }}">
488 <# if ( data.uploading ) { #>
489 <div class="media-progress-bar"><div></div></div>
490 <# } else if ( 'image' === data.type && data.sizes ) { #>
491 <img src="{{ data.size.url }}" draggable="false" />
493 <img src="{{ data.icon }}" class="icon" draggable="false" />
496 <div class="details">
497 <div class="filename">{{ data.filename }}</div>
498 <div class="uploaded">{{ data.dateFormatted }}</div>
500 <div class="file-size">{{ data.filesizeHumanReadable }}</div>
501 <# if ( 'image' === data.type && ! data.uploading ) { #>
502 <# if ( data.width && data.height ) { #>
503 <div class="dimensions">{{ data.width }} × {{ data.height }}</div>
506 <# if ( data.can.save && data.sizes ) { #>
507 <a class="edit-attachment" href="{{ data.editLink }}&image-editor" target="_blank"><?php _e( 'Edit Image' ); ?></a>
508 <a class="refresh-attachment" href="#"><?php _e( 'Refresh' ); ?></a>
512 <# if ( data.fileLength ) { #>
513 <div class="file-length"><?php _e( 'Length:' ); ?> {{ data.fileLength }}</div>
516 <# if ( ! data.uploading && data.can.remove ) { #>
517 <?php if ( MEDIA_TRASH ): ?>
518 <# if ( 'trash' === data.status ) { #>
519 <a class="untrash-attachment" href="#"><?php _e( 'Untrash' ); ?></a>
521 <a class="trash-attachment" href="#"><?php _e( 'Trash' ); ?></a>
524 <a class="delete-attachment" href="#"><?php _e( 'Delete Permanently' ); ?></a>
528 <div class="compat-meta">
529 <# if ( data.compat && data.compat.meta ) { #>
530 {{{ data.compat.meta }}}
536 <label class="setting" data-setting="url">
537 <span class="name"><?php _e('URL'); ?></span>
538 <input type="text" value="{{ data.url }}" readonly />
540 <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #>
541 <label class="setting" data-setting="title">
542 <span class="name"><?php _e('Title'); ?></span>
543 <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} />
545 <# if ( 'audio' === data.type ) { #>
546 <?php foreach ( array(
547 'artist' => __( 'Artist' ),
548 'album' => __( 'Album' ),
549 ) as $key => $label ) : ?>
550 <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>">
551 <span class="name"><?php echo $label ?></span>
552 <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" />
556 <label class="setting" data-setting="caption">
557 <span class="name"><?php _e('Caption'); ?></span>
558 <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea>
560 <# if ( 'image' === data.type ) { #>
561 <label class="setting" data-setting="alt">
562 <span class="name"><?php _e('Alt Text'); ?></span>
563 <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} />
566 <label class="setting" data-setting="description">
567 <span class="name"><?php _e('Description'); ?></span>
568 <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea>
572 <script type="text/html" id="tmpl-media-selection">
573 <div class="selection-info">
574 <span class="count"></span>
575 <# if ( data.editable ) { #>
576 <a class="edit-selection" href="#"><?php _e('Edit'); ?></a>
578 <# if ( data.clearable ) { #>
579 <a class="clear-selection" href="#"><?php _e('Clear'); ?></a>
582 <div class="selection-view"></div>
585 <script type="text/html" id="tmpl-attachment-display-settings">
586 <h3><?php _e('Attachment Display Settings'); ?></h3>
588 <# if ( 'image' === data.type ) { #>
589 <label class="setting">
590 <span><?php _e('Alignment'); ?></span>
591 <select class="alignment"
593 <# if ( data.userSettings ) { #>
594 data-user-setting="align"
597 <option value="left">
598 <?php esc_attr_e('Left'); ?>
600 <option value="center">
601 <?php esc_attr_e('Center'); ?>
603 <option value="right">
604 <?php esc_attr_e('Right'); ?>
606 <option value="none" selected>
607 <?php esc_attr_e('None'); ?>
613 <div class="setting">
615 <# if ( data.model.canEmbed ) { #>
616 <span><?php _e('Embed or Link'); ?></span>
618 <span><?php _e('Link To'); ?></span>
621 <select class="link-to"
623 <# if ( data.userSettings && ! data.model.canEmbed ) { #>
624 data-user-setting="urlbutton"
627 <# if ( data.model.canEmbed ) { #>
628 <option value="embed" selected>
629 <?php esc_attr_e('Embed Media Player'); ?>
631 <option value="file">
633 <option value="file" selected>
635 <# if ( data.model.canEmbed ) { #>
636 <?php esc_attr_e('Link to Media File'); ?>
638 <?php esc_attr_e('Media File'); ?>
641 <option value="post">
642 <# if ( data.model.canEmbed ) { #>
643 <?php esc_attr_e('Link to Attachment Page'); ?>
645 <?php esc_attr_e('Attachment Page'); ?>
648 <# if ( 'image' === data.type ) { #>
649 <option value="custom">
650 <?php esc_attr_e('Custom URL'); ?>
652 <option value="none">
653 <?php esc_attr_e('None'); ?>
658 <input type="text" class="link-to-custom" data-setting="linkUrl" />
661 <# if ( 'undefined' !== typeof data.sizes ) { #>
662 <label class="setting">
663 <span><?php _e('Size'); ?></span>
664 <select class="size" name="size"
666 <# if ( data.userSettings ) { #>
667 data-user-setting="imgsize"
670 /** This filter is documented in wp-admin/includes/media.php */
671 $sizes = apply_filters( 'image_size_names_choose', array(
672 'thumbnail' => __('Thumbnail'),
673 'medium' => __('Medium'),
674 'large' => __('Large'),
675 'full' => __('Full Size'),
678 foreach ( $sizes as $value => $name ) : ?>
680 var size = data.sizes['<?php echo esc_js( $value ); ?>'];
682 <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'full' ); ?>>
683 <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }}
692 <script type="text/html" id="tmpl-gallery-settings">
693 <h3><?php _e('Gallery Settings'); ?></h3>
695 <label class="setting">
696 <span><?php _e('Link To'); ?></span>
697 <select class="link-to"
699 <# if ( data.userSettings ) { #>
700 data-user-setting="urlbutton"
703 <option value="post" <# if ( ! wp.media.galleryDefaults.link || 'post' == wp.media.galleryDefaults.link ) {
704 #>selected="selected"<# }
706 <?php esc_attr_e('Attachment Page'); ?>
708 <option value="file" <# if ( 'file' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>>
709 <?php esc_attr_e('Media File'); ?>
711 <option value="none" <# if ( 'none' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>>
712 <?php esc_attr_e('None'); ?>
717 <label class="setting">
718 <span><?php _e('Columns'); ?></span>
719 <select class="columns" name="columns"
720 data-setting="columns">
721 <?php for ( $i = 1; $i <= 9; $i++ ) : ?>
722 <option value="<?php echo esc_attr( $i ); ?>" <#
723 if ( <?php echo $i ?> == wp.media.galleryDefaults.columns ) { #>selected="selected"<# }
725 <?php echo esc_html( $i ); ?>
731 <label class="setting">
732 <span><?php _e( 'Random Order' ); ?></span>
733 <input type="checkbox" data-setting="_orderbyRandom" />
737 <script type="text/html" id="tmpl-playlist-settings">
738 <h3><?php _e( 'Playlist Settings' ); ?></h3>
740 <# var emptyModel = _.isEmpty( data.model ),
741 isVideo = 'video' === data.controller.get('library').props.get('type'); #>
743 <label class="setting">
744 <input type="checkbox" data-setting="tracklist" <# if ( emptyModel ) { #>
747 <# if ( isVideo ) { #>
748 <span><?php _e( 'Show Video List' ); ?></span>
750 <span><?php _e( 'Show Tracklist' ); ?></span>
754 <# if ( ! isVideo ) { #>
755 <label class="setting">
756 <input type="checkbox" data-setting="artists" <# if ( emptyModel ) { #>
759 <span><?php _e( 'Show Artist Name in Tracklist' ); ?></span>
763 <label class="setting">
764 <input type="checkbox" data-setting="images" <# if ( emptyModel ) { #>
767 <span><?php _e( 'Show Images' ); ?></span>
771 <script type="text/html" id="tmpl-embed-link-settings">
772 <label class="setting title">
773 <span><?php _e( 'Title' ); ?></span>
774 <input type="text" class="alignment" data-setting="title" />
776 <div class="embed-container" style="display: none;">
777 <div class="embed-preview"></div>
781 <script type="text/html" id="tmpl-embed-image-settings">
782 <div class="thumbnail">
783 <img src="{{ data.model.url }}" draggable="false" />
787 /** This filter is documented in wp-admin/includes/media.php */
788 if ( ! apply_filters( 'disable_captions', '' ) ) : ?>
789 <label class="setting caption">
790 <span><?php _e('Caption'); ?></span>
791 <textarea data-setting="caption" />
795 <label class="setting alt-text">
796 <span><?php _e('Alt Text'); ?></span>
797 <input type="text" data-setting="alt" />
800 <div class="setting align">
801 <span><?php _e('Align'); ?></span>
802 <div class="button-group button-large" data-setting="align">
803 <button class="button" value="left">
804 <?php esc_attr_e('Left'); ?>
806 <button class="button" value="center">
807 <?php esc_attr_e('Center'); ?>
809 <button class="button" value="right">
810 <?php esc_attr_e('Right'); ?>
812 <button class="button active" value="none">
813 <?php esc_attr_e('None'); ?>
818 <div class="setting link-to">
819 <span><?php _e('Link To'); ?></span>
820 <div class="button-group button-large" data-setting="link">
821 <button class="button" value="file">
822 <?php esc_attr_e('Image URL'); ?>
824 <button class="button" value="custom">
825 <?php esc_attr_e('Custom URL'); ?>
827 <button class="button active" value="none">
828 <?php esc_attr_e('None'); ?>
831 <input type="text" class="link-to-custom" data-setting="linkUrl" />
835 <script type="text/html" id="tmpl-image-details">
836 <div class="media-embed">
837 <div class="embed-media-settings">
838 <div class="column-image">
840 <img src="{{ data.model.url }}" draggable="false" />
842 <# if ( data.attachment && window.imageEdit ) { #>
843 <div class="actions">
844 <input type="button" class="edit-attachment button" value="<?php esc_attr_e( 'Edit Original' ); ?>" />
845 <input type="button" class="replace-attachment button" value="<?php esc_attr_e( 'Replace' ); ?>" />
850 <div class="column-settings">
852 /** This filter is documented in wp-admin/includes/media.php */
853 if ( ! apply_filters( 'disable_captions', '' ) ) : ?>
854 <label class="setting caption">
855 <span><?php _e('Caption'); ?></span>
856 <textarea data-setting="caption">{{ data.model.caption }}</textarea>
860 <label class="setting alt-text">
861 <span><?php _e('Alternative Text'); ?></span>
862 <input type="text" data-setting="alt" value="{{ data.model.alt }}" />
865 <h3><?php _e( 'Display Settings' ); ?></h3>
866 <div class="setting align">
867 <span><?php _e('Align'); ?></span>
868 <div class="button-group button-large" data-setting="align">
869 <button class="button" value="left">
870 <?php esc_attr_e('Left'); ?>
872 <button class="button" value="center">
873 <?php esc_attr_e('Center'); ?>
875 <button class="button" value="right">
876 <?php esc_attr_e('Right'); ?>
878 <button class="button active" value="none">
879 <?php esc_attr_e('None'); ?>
884 <# if ( data.attachment ) { #>
885 <# if ( 'undefined' !== typeof data.attachment.sizes ) { #>
886 <label class="setting size">
887 <span><?php _e('Size'); ?></span>
888 <select class="size" name="size"
890 <# if ( data.userSettings ) { #>
891 data-user-setting="imgsize"
894 /** This filter is documented in wp-admin/includes/media.php */
895 $sizes = apply_filters( 'image_size_names_choose', array(
896 'thumbnail' => __('Thumbnail'),
897 'medium' => __('Medium'),
898 'large' => __('Large'),
899 'full' => __('Full Size'),
902 foreach ( $sizes as $value => $name ) : ?>
904 var size = data.sizes['<?php echo esc_js( $value ); ?>'];
906 <option value="<?php echo esc_attr( $value ); ?>">
907 <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }}
911 <option value="<?php echo esc_attr( 'custom' ); ?>">
912 <?php _e( 'Custom Size' ); ?>
917 <div class="custom-size<# if ( data.model.size !== 'custom' ) { #> hidden<# } #>">
918 <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>
922 <div class="setting link-to">
923 <span><?php _e('Link To'); ?></span>
924 <select data-setting="link">
925 <# if ( data.attachment ) { #>
926 <option value="file">
927 <?php esc_attr_e('Media File'); ?>
929 <option value="post">
930 <?php esc_attr_e('Attachment Page'); ?>
933 <option value="file">
934 <?php esc_attr_e('Image URL'); ?>
937 <option value="custom">
938 <?php esc_attr_e('Custom URL'); ?>
940 <option value="none">
941 <?php esc_attr_e('None'); ?>
944 <input type="text" class="link-to-custom" data-setting="linkUrl" />
946 <div class="advanced-section">
947 <h3><a class="advanced-toggle" href="#"><?php _e('Advanced Options'); ?></a></h3>
948 <div class="advanced-settings hidden">
949 <div class="advanced-image">
950 <label class="setting title-text">
951 <span><?php _e('Image Title Attribute'); ?></span>
952 <input type="text" data-setting="title" value="{{ data.model.title }}" />
954 <label class="setting extra-classes">
955 <span><?php _e('Image CSS Class'); ?></span>
956 <input type="text" data-setting="extraClasses" value="{{ data.model.extraClasses }}" />
959 <div class="advanced-link">
960 <div class="setting link-target">
961 <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>
963 <label class="setting link-rel">
964 <span><?php _e('Link Rel'); ?></span>
965 <input type="text" data-setting="linkRel" value="{{ data.model.linkClassName }}" />
967 <label class="setting link-class-name">
968 <span><?php _e('Link CSS Class'); ?></span>
969 <input type="text" data-setting="linkClassName" value="{{ data.model.linkClassName }}" />
979 <script type="text/html" id="tmpl-image-editor">
980 <div id="media-head-{{ data.id }}"></div>
981 <div id="image-editor-{{ data.id }}"></div>
984 <script type="text/html" id="tmpl-audio-details">
985 <# var ext, html5types = {
986 mp3: wp.media.view.settings.embedMimes.mp3,
987 ogg: wp.media.view.settings.embedMimes.ogg
990 <?php $audio_types = wp_get_audio_extensions(); ?>
991 <div class="media-embed media-embed-details">
992 <div class="embed-media-settings embed-audio-settings">
993 <?php wp_underscore_audio_template() ?>
995 <# if ( ! _.isEmpty( data.model.src ) ) {
996 ext = data.model.src.split('.').pop();
997 if ( html5types[ ext ] ) {
998 delete html5types[ ext ];
1001 <label class="setting">
1003 <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" />
1004 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1009 foreach ( $audio_types as $type ):
1010 ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) {
1011 if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) {
1012 delete html5types.<?php echo $type ?>;
1015 <label class="setting">
1016 <span><?php echo strtoupper( $type ) ?></span>
1017 <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" />
1018 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1023 <# if ( ! _.isEmpty( html5types ) ) { #>
1024 <div class="setting">
1025 <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ) ?></span>
1026 <div class="button-large">
1027 <# _.each( html5types, function (mime, type) { #>
1028 <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button>
1034 <div class="setting preload">
1035 <span><?php _e( 'Preload' ); ?></span>
1036 <div class="button-group button-large" data-setting="preload">
1037 <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button>
1038 <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button>
1039 <button class="button active" value="none"><?php _e( 'None' ); ?></button>
1043 <label class="setting checkbox-setting">
1044 <input type="checkbox" data-setting="autoplay" />
1045 <span><?php _e( 'Autoplay' ); ?></span>
1048 <label class="setting checkbox-setting">
1049 <input type="checkbox" data-setting="loop" />
1050 <span><?php _e( 'Loop' ); ?></span>
1056 <script type="text/html" id="tmpl-video-details">
1057 <# var ext, html5types = {
1058 mp4: wp.media.view.settings.embedMimes.mp4,
1059 ogv: wp.media.view.settings.embedMimes.ogv,
1060 webm: wp.media.view.settings.embedMimes.webm
1063 <?php $video_types = wp_get_video_extensions(); ?>
1064 <div class="media-embed media-embed-details">
1065 <div class="embed-media-settings embed-video-settings">
1066 <div class="wp-video-holder">
1068 var isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/);
1069 w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width,
1070 h = ! data.model.height ? 360 : data.model.height;
1072 if ( data.model.width && w !== data.model.width ) {
1073 h = Math.ceil( ( h * w ) / data.model.width );
1077 <?php wp_underscore_video_template() ?>
1079 <# if ( ! _.isEmpty( data.model.src ) ) {
1080 ext = data.model.src.split('.').pop();
1081 if ( html5types[ ext ] ) {
1082 delete html5types[ ext ];
1085 <label class="setting">
1087 <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" />
1088 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1091 <?php foreach ( $video_types as $type ):
1092 ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) {
1093 if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) {
1094 delete html5types.<?php echo $type ?>;
1097 <label class="setting">
1098 <span><?php echo strtoupper( $type ) ?></span>
1099 <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" />
1100 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1106 <# if ( ! _.isEmpty( html5types ) ) { #>
1107 <div class="setting">
1108 <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ); ?></span>
1109 <div class="button-large">
1110 <# _.each( html5types, function (mime, type) { #>
1111 <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button>
1117 <# if ( ! _.isEmpty( data.model.poster ) ) { #>
1118 <label class="setting">
1119 <span><?php _e( 'Poster Image' ); ?></span>
1120 <input type="text" disabled="disabled" data-setting="poster" value="{{ data.model.poster }}" />
1121 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1124 <div class="setting preload">
1125 <span><?php _e( 'Preload' ); ?></span>
1126 <div class="button-group button-large" data-setting="preload">
1127 <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button>
1128 <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button>
1129 <button class="button active" value="none"><?php _e( 'None' ); ?></button>
1133 <label class="setting checkbox-setting">
1134 <input type="checkbox" data-setting="autoplay" />
1135 <span><?php _e( 'Autoplay' ); ?></span>
1138 <label class="setting checkbox-setting">
1139 <input type="checkbox" data-setting="loop" />
1140 <span><?php _e( 'Loop' ); ?></span>
1143 <label class="setting" data-setting="content">
1144 <span><?php _e( 'Tracks (subtitles, captions, descriptions, chapters, or metadata)' ); ?></span>
1147 if ( ! _.isEmpty( data.model.content ) ) {
1148 var tracks = jQuery( data.model.content ).filter( 'track' );
1149 _.each( tracks.toArray(), function (track) {
1150 content += track.outerHTML; #>
1152 <input class="content-track" type="text" value="{{ track.outerHTML }}" />
1153 <a class="remove-setting remove-track"><?php _e( 'Remove' ); ?></a>
1157 <em><?php _e( 'There are no associated subtitles.' ); ?></em>
1159 <textarea class="hidden content-setting">{{ content }}</textarea>
1165 <script type="text/html" id="tmpl-editor-gallery">
1166 <# if ( data.attachments ) { #>
1167 <div class="gallery gallery-columns-{{ data.columns }}">
1168 <# _.each( data.attachments, function( attachment, index ) { #>
1169 <dl class="gallery-item">
1170 <dt class="gallery-icon">
1171 <# if ( attachment.thumbnail ) { #>
1172 <img src="{{ attachment.thumbnail.url }}" width="{{ attachment.thumbnail.width }}" height="{{ attachment.thumbnail.height }}" />
1174 <img src="{{ attachment.url }}" />
1177 <# if ( attachment.caption ) { #>
1178 <dd class="wp-caption-text gallery-caption">
1179 {{ attachment.caption }}
1183 <# if ( index % data.columns === data.columns - 1 ) { #>
1184 <br style="clear: both;">
1189 <div class="wpview-error">
1190 <div class="dashicons dashicons-format-gallery"></div><p><?php _e( 'No items found.' ); ?></p>
1195 <script type="text/html" id="tmpl-crop-content">
1196 <img class="crop-image" src="{{ data.url }}">
1197 <div class="upload-errors"></div>
1203 * Fires when the custom Backbone media templates are printed.
1207 do_action( 'print_media_templates' );