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 = '', classes = [],
54 w, h, settings = wp.media.view.settings,
55 isYouTube = isVimeo = false;
57 if ( ! _.isEmpty( data.model.src ) ) {
58 isYouTube = data.model.src.match(/youtube|youtu\.be/);
59 isVimeo = -1 !== data.model.src.indexOf('vimeo');
62 if ( settings.contentWidth && data.model.width >= settings.contentWidth ) {
63 w = settings.contentWidth;
68 if ( w !== data.model.width ) {
69 h = Math.ceil( ( data.model.height * w ) / data.model.width );
71 h = data.model.height;
75 w_rule = 'width: ' + w + 'px; ';
78 h_rule = 'height: ' + h + 'px;';
82 classes.push( 'youtube-video' );
86 classes.push( 'vimeo-video' );
90 <div style="{{ w_rule }}{{ h_rule }}" class="wp-video">
92 class="wp-video-shortcode {{ classes.join( ' ' ) }}"
93 <# if ( w ) { #>width="{{ w }}"<# } #>
94 <# if ( h ) { #>height="{{ h }}"<# } #>
96 $props = array( 'poster' => '', 'preload' => 'metadata' );
97 foreach ( $props as $key => $value ):
98 if ( empty( $value ) ) {
100 if ( ! _.isUndefined( data.model.<?php echo $key ?> ) && data.model.<?php echo $key ?> ) {
101 #> <?php echo $key ?>="{{ data.model.<?php echo $key ?> }}"<#
104 echo $key ?>="{{ _.isUndefined( data.model.<?php echo $key ?> ) ? '<?php echo $value ?>' : data.model.<?php echo $key ?> }}"<?php
108 <?php foreach ( array( 'autoplay', 'loop' ) as $attr ):
109 ?> if ( ! _.isUndefined( data.model.<?php echo $attr ?> ) && data.model.<?php echo $attr ?> ) {
110 #> <?php echo $attr ?><#
112 <?php endforeach ?>#>
114 <# if ( ! _.isEmpty( data.model.src ) ) {
115 if ( isYouTube ) { #>
116 <source src="{{ data.model.src }}" type="video/youtube" />
117 <# } else if ( isVimeo ) { #>
118 <source src="{{ data.model.src }}" type="video/vimeo" />
120 <source src="{{ data.model.src }}" type="{{ settings.embedMimes[ data.model.src.split('.').pop() ] }}" />
124 <?php foreach ( $video_types as $type ):
125 ?><# if ( data.model.<?php echo $type ?> ) { #>
126 <source src="{{ data.model.<?php echo $type ?> }}" type="{{ settings.embedMimes[ '<?php echo $type ?>' ] }}" />
129 {{{ data.model.content }}}
136 * Prints the templates used in the media manager.
140 function wp_print_media_templates() {
142 $class = 'media-modal wp-core-ui';
143 if ( $is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false )
149 outline: #1e8cbe solid;
151 .selected.attachment {
152 outline: #1e8cbe solid;
156 <script type="text/html" id="tmpl-media-frame">
157 <div class="media-frame-menu"></div>
158 <div class="media-frame-title"></div>
159 <div class="media-frame-router"></div>
160 <div class="media-frame-content"></div>
161 <div class="media-frame-toolbar"></div>
162 <div class="media-frame-uploader"></div>
165 <script type="text/html" id="tmpl-media-modal">
166 <div class="<?php echo $class; ?>">
167 <a class="media-modal-close" href="#"><span class="media-modal-icon"><span class="screen-reader-text"><?php _e( 'Close media panel' ); ?></span></span></a>
168 <div class="media-modal-content"></div>
170 <div class="media-modal-backdrop"></div>
173 <script type="text/html" id="tmpl-uploader-window">
174 <div class="uploader-window-content">
175 <h3><?php _e( 'Drop files to upload' ); ?></h3>
179 <script type="text/html" id="tmpl-uploader-editor">
180 <div class="uploader-editor-content">
181 <div class="uploader-editor-title"><?php _e( 'Drop files to upload' ); ?></div>
185 <script type="text/html" id="tmpl-uploader-inline">
186 <# var messageClass = data.message ? 'has-upload-message' : 'no-upload-message'; #>
187 <# if ( data.canClose ) { #>
188 <button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close uploader' ); ?></span></button>
190 <div class="uploader-inline-content {{ messageClass }}">
191 <# if ( data.message ) { #>
192 <h3 class="upload-message">{{ data.message }}</h3>
194 <?php if ( ! _device_can_upload() ) : ?>
195 <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>
196 <?php elseif ( is_multisite() && ! is_upload_space_available() ) : ?>
197 <h3 class="upload-instructions"><?php _e( 'Upload Limit Exceeded' ); ?></h3>
199 /** This action is documented in wp-admin/includes/media.php */
200 do_action( 'upload_ui_over_quota' ); ?>
203 <div class="upload-ui">
204 <h3 class="upload-instructions drop-instructions"><?php _e( 'Drop files anywhere to upload' ); ?></h3>
205 <p class="upload-instructions drop-instructions"><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p>
206 <a href="#" class="browser button button-hero"><?php _e( 'Select Files' ); ?></a>
209 <div class="upload-inline-status"></div>
211 <div class="post-upload-ui">
213 /** This action is documented in wp-admin/includes/media.php */
214 do_action( 'pre-upload-ui' );
215 /** This action is documented in wp-admin/includes/media.php */
216 do_action( 'pre-plupload-upload-ui' );
218 if ( 10 === remove_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ) ) {
219 /** This action is documented in wp-admin/includes/media.php */
220 do_action( 'post-plupload-upload-ui' );
221 add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' );
223 /** This action is documented in wp-admin/includes/media.php */
224 do_action( 'post-plupload-upload-ui' );
227 $max_upload_size = wp_max_upload_size();
228 if ( ! $max_upload_size ) {
229 $max_upload_size = 0;
233 <p class="max-upload-size"><?php
234 printf( __( 'Maximum upload file size: %s.' ), esc_html( size_format( $max_upload_size ) ) );
237 <# if ( data.suggestedWidth && data.suggestedHeight ) { #>
238 <p class="suggested-dimensions">
239 <?php _e( 'Suggested image dimensions:' ); ?> {{data.suggestedWidth}} × {{data.suggestedHeight}}
244 /** This action is documented in wp-admin/includes/media.php */
245 do_action( 'post-upload-ui' ); ?>
251 <script type="text/html" id="tmpl-media-library-view-switcher">
252 <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-list">
253 <span class="screen-reader-text"><?php _e( 'List View' ); ?></span>
255 <a href="<?php echo esc_url( add_query_arg( 'mode', 'grid', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-grid current">
256 <span class="screen-reader-text"><?php _e( 'Grid View' ); ?></span>
260 <script type="text/html" id="tmpl-uploader-status">
261 <h3><?php _e( 'Uploading' ); ?></h3>
262 <a class="upload-dismiss-errors" href="#"><?php _e('Dismiss Errors'); ?></a>
264 <div class="media-progress-bar"><div></div></div>
265 <div class="upload-details">
266 <span class="upload-count">
267 <span class="upload-index"></span> / <span class="upload-total"></span>
269 <span class="upload-detail-separator">–</span>
270 <span class="upload-filename"></span>
272 <div class="upload-errors"></div>
275 <script type="text/html" id="tmpl-uploader-status-error">
276 <span class="upload-error-label"><?php _e('Error'); ?></span>
277 <span class="upload-error-filename">{{{ data.filename }}}</span>
278 <span class="upload-error-message">{{ data.message }}</span>
281 <script type="text/html" id="tmpl-edit-attachment-frame">
282 <div class="edit-media-header">
283 <button class="left dashicons <# if ( ! data.hasPrevious ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit previous media item' ); ?></span></button>
284 <button class="right dashicons <# if ( ! data.hasNext ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit next media item' ); ?></span></button>
286 <div class="media-frame-title"></div>
287 <div class="media-frame-content"></div>
290 <script type="text/html" id="tmpl-attachment-details-two-column">
291 <div class="attachment-media-view {{ data.orientation }}">
292 <div class="thumbnail thumbnail-{{ data.type }}">
293 <# if ( data.uploading ) { #>
294 <div class="media-progress-bar"><div></div></div>
295 <# } else if ( 'image' === data.type && data.sizes && data.sizes.large ) { #>
296 <img class="details-image" src="{{ data.sizes.large.url }}" draggable="false" />
297 <# } else if ( 'image' === data.type && data.sizes && data.sizes.full ) { #>
298 <img class="details-image" src="{{ data.sizes.full.url }}" draggable="false" />
299 <# } else if ( -1 === jQuery.inArray( data.type, [ 'audio', 'video' ] ) ) { #>
300 <img class="details-image" src="{{ data.icon }}" class="icon" draggable="false" />
303 <# if ( 'audio' === data.type ) { #>
304 <div class="wp-media-wrapper">
305 <audio style="visibility: hidden" controls class="wp-audio-shortcode" width="100%" preload="none">
306 <source type="{{ data.mime }}" src="{{ data.url }}"/>
309 <# } else if ( 'video' === data.type ) {
310 var w_rule = h_rule = '';
312 w_rule = 'width: ' + data.width + 'px;';
313 } else if ( wp.media.view.settings.contentWidth ) {
314 w_rule = 'width: ' + wp.media.view.settings.contentWidth + 'px;';
317 h_rule = 'height: ' + data.height + 'px;';
320 <div style="{{ w_rule }}{{ h_rule }}" class="wp-media-wrapper wp-video">
321 <video controls="controls" class="wp-video-shortcode" preload="metadata"
322 <# if ( data.width ) { #>width="{{ data.width }}"<# } #>
323 <# if ( data.height ) { #>height="{{ data.height }}"<# } #>
324 <# if ( data.image && data.image.src !== data.icon ) { #>poster="{{ data.image.src }}"<# } #>>
325 <source type="{{ data.mime }}" src="{{ data.url }}"/>
330 <div class="attachment-actions">
331 <# if ( 'image' === data.type && ! data.uploading && data.sizes && data.can.save ) { #>
332 <a class="button edit-attachment" href="#"><?php _e( 'Edit Image' ); ?></a>
337 <div class="attachment-info">
338 <span class="settings-save-status">
339 <span class="spinner"></span>
340 <span class="saved"><?php esc_html_e('Saved.'); ?></span>
342 <div class="details">
343 <div class="filename"><strong><?php _e( 'File name:' ); ?></strong> {{ data.filename }}</div>
344 <div class="filename"><strong><?php _e( 'File type:' ); ?></strong> {{ data.mime }}</div>
345 <div class="uploaded"><strong><?php _e( 'Uploaded on:' ); ?></strong> {{ data.dateFormatted }}</div>
347 <div class="file-size"><strong><?php _e( 'File size:' ); ?></strong> {{ data.filesizeHumanReadable }}</div>
348 <# if ( 'image' === data.type && ! data.uploading ) { #>
349 <# if ( data.width && data.height ) { #>
350 <div class="dimensions"><strong><?php _e( 'Dimensions:' ); ?></strong> {{ data.width }} × {{ data.height }}</div>
354 <# if ( data.fileLength ) { #>
355 <div class="file-length"><strong><?php _e( 'Length:' ); ?></strong> {{ data.fileLength }}</div>
358 <# if ( 'audio' === data.type && data.meta.bitrate ) { #>
359 <div class="bitrate">
360 <strong><?php _e( 'Bitrate:' ); ?></strong> {{ Math.round( data.meta.bitrate / 1000 ) }}kb/s
361 <# if ( data.meta.bitrate_mode ) { #>
362 {{ ' ' + data.meta.bitrate_mode.toUpperCase() }}
367 <div class="compat-meta">
368 <# if ( data.compat && data.compat.meta ) { #>
369 {{{ data.compat.meta }}}
374 <div class="settings">
375 <label class="setting" data-setting="url">
376 <span class="name"><?php _e('URL'); ?></span>
377 <input type="text" value="{{ data.url }}" readonly />
379 <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #>
380 <label class="setting" data-setting="title">
381 <span class="name"><?php _e('Title'); ?></span>
382 <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} />
384 <# if ( 'audio' === data.type ) { #>
385 <?php foreach ( array(
386 'artist' => __( 'Artist' ),
387 'album' => __( 'Album' ),
388 ) as $key => $label ) : ?>
389 <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>">
390 <span class="name"><?php echo $label ?></span>
391 <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" />
395 <label class="setting" data-setting="caption">
396 <span class="name"><?php _e( 'Caption' ); ?></span>
397 <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea>
399 <# if ( 'image' === data.type ) { #>
400 <label class="setting" data-setting="alt">
401 <span class="name"><?php _e( 'Alt Text' ); ?></span>
402 <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} />
405 <label class="setting" data-setting="description">
406 <span class="name"><?php _e('Description'); ?></span>
407 <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea>
409 <label class="setting">
410 <span class="name"><?php _e( 'Uploaded By' ); ?></span>
411 <span class="value">{{ data.authorName }}</span>
413 <# if ( data.uploadedToTitle ) { #>
414 <label class="setting">
415 <span class="name"><?php _e( 'Uploaded To' ); ?></span>
416 <# if ( data.uploadedToLink ) { #>
417 <span class="value"><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a></span>
419 <span class="value">{{ data.uploadedToTitle }}</span>
423 <div class="attachment-compat"></div>
426 <div class="actions">
427 <a class="view-attachment" href="{{ data.link }}"><?php _e( 'View attachment page' ); ?></a>
428 <# if ( data.can.save ) { #> |
429 <a href="post.php?post={{ data.id }}&action=edit"><?php _e( 'Edit more details' ); ?></a>
431 <# if ( ! data.uploading && data.can.remove ) { #> |
432 <?php if ( MEDIA_TRASH ): ?>
433 <# if ( 'trash' === data.status ) { #>
434 <a class="untrash-attachment" href="#"><?php _e( 'Untrash' ); ?></a>
436 <a class="trash-attachment" href="#"><?php _ex( 'Trash', 'verb' ); ?></a>
439 <a class="delete-attachment" href="#"><?php _e( 'Delete Permanently' ); ?></a>
447 <script type="text/html" id="tmpl-attachment">
448 <div class="attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">
449 <div class="thumbnail">
450 <# if ( data.uploading ) { #>
451 <div class="media-progress-bar"><div style="width: {{ data.percent }}%"></div></div>
452 <# } else if ( 'image' === data.type && data.sizes ) { #>
453 <div class="centered">
454 <img src="{{ data.size.url }}" draggable="false" alt="" />
457 <div class="centered">
458 <# if ( data.image && data.image.src && data.image.src !== data.icon ) { #>
459 <img src="{{ data.image.src }}" class="thumbnail" draggable="false" />
461 <img src="{{ data.icon }}" class="icon" draggable="false" />
464 <div class="filename">
465 <div>{{ data.filename }}</div>
469 <# if ( data.buttons.close ) { #>
470 <a class="close media-modal-icon" href="#" title="<?php esc_attr_e('Remove'); ?>"></a>
473 <# if ( data.buttons.check ) { #>
474 <a class="check" href="#" title="<?php esc_attr_e('Deselect'); ?>" tabindex="-1"><div class="media-modal-icon"></div></a>
477 var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly';
478 if ( data.describe ) {
479 if ( 'image' === data.type ) { #>
480 <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption"
481 placeholder="<?php esc_attr_e('Caption this image…'); ?>" {{ maybeReadOnly }} />
483 <input type="text" value="{{ data.title }}" class="describe" data-setting="title"
484 <# if ( 'video' === data.type ) { #>
485 placeholder="<?php esc_attr_e('Describe this video…'); ?>"
486 <# } else if ( 'audio' === data.type ) { #>
487 placeholder="<?php esc_attr_e('Describe this audio file…'); ?>"
489 placeholder="<?php esc_attr_e('Describe this media file…'); ?>"
490 <# } #> {{ maybeReadOnly }} />
495 <script type="text/html" id="tmpl-attachment-details">
497 <?php _e('Attachment Details'); ?>
499 <span class="settings-save-status">
500 <span class="spinner"></span>
501 <span class="saved"><?php esc_html_e('Saved.'); ?></span>
504 <div class="attachment-info">
505 <div class="thumbnail thumbnail-{{ data.type }}">
506 <# if ( data.uploading ) { #>
507 <div class="media-progress-bar"><div></div></div>
508 <# } else if ( 'image' === data.type && data.sizes ) { #>
509 <img src="{{ data.size.url }}" draggable="false" />
511 <img src="{{ data.icon }}" class="icon" draggable="false" />
514 <div class="details">
515 <div class="filename">{{ data.filename }}</div>
516 <div class="uploaded">{{ data.dateFormatted }}</div>
518 <div class="file-size">{{ data.filesizeHumanReadable }}</div>
519 <# if ( 'image' === data.type && ! data.uploading ) { #>
520 <# if ( data.width && data.height ) { #>
521 <div class="dimensions">{{ data.width }} × {{ data.height }}</div>
524 <# if ( data.can.save && data.sizes ) { #>
525 <a class="edit-attachment" href="{{ data.editLink }}&image-editor" target="_blank"><?php _e( 'Edit Image' ); ?></a>
526 <a class="refresh-attachment" href="#"><?php _e( 'Refresh' ); ?></a>
530 <# if ( data.fileLength ) { #>
531 <div class="file-length"><?php _e( 'Length:' ); ?> {{ data.fileLength }}</div>
534 <# if ( ! data.uploading && data.can.remove ) { #>
535 <?php if ( MEDIA_TRASH ): ?>
536 <# if ( 'trash' === data.status ) { #>
537 <a class="untrash-attachment" href="#"><?php _e( 'Untrash' ); ?></a>
539 <a class="trash-attachment" href="#"><?php _ex( 'Trash', 'verb' ); ?></a>
542 <a class="delete-attachment" href="#"><?php _e( 'Delete Permanently' ); ?></a>
546 <div class="compat-meta">
547 <# if ( data.compat && data.compat.meta ) { #>
548 {{{ data.compat.meta }}}
554 <label class="setting" data-setting="url">
555 <span class="name"><?php _e('URL'); ?></span>
556 <input type="text" value="{{ data.url }}" readonly />
558 <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #>
559 <label class="setting" data-setting="title">
560 <span class="name"><?php _e('Title'); ?></span>
561 <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} />
563 <# if ( 'audio' === data.type ) { #>
564 <?php foreach ( array(
565 'artist' => __( 'Artist' ),
566 'album' => __( 'Album' ),
567 ) as $key => $label ) : ?>
568 <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>">
569 <span class="name"><?php echo $label ?></span>
570 <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" />
574 <label class="setting" data-setting="caption">
575 <span class="name"><?php _e('Caption'); ?></span>
576 <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea>
578 <# if ( 'image' === data.type ) { #>
579 <label class="setting" data-setting="alt">
580 <span class="name"><?php _e('Alt Text'); ?></span>
581 <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} />
584 <label class="setting" data-setting="description">
585 <span class="name"><?php _e('Description'); ?></span>
586 <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea>
590 <script type="text/html" id="tmpl-media-selection">
591 <div class="selection-info">
592 <span class="count"></span>
593 <# if ( data.editable ) { #>
594 <a class="edit-selection" href="#"><?php _e( 'Edit Selection' ); ?></a>
596 <# if ( data.clearable ) { #>
597 <a class="clear-selection" href="#"><?php _e('Clear'); ?></a>
600 <div class="selection-view"></div>
603 <script type="text/html" id="tmpl-attachment-display-settings">
604 <h3><?php _e('Attachment Display Settings'); ?></h3>
606 <# if ( 'image' === data.type ) { #>
607 <label class="setting">
608 <span><?php _e('Alignment'); ?></span>
609 <select class="alignment"
611 <# if ( data.userSettings ) { #>
612 data-user-setting="align"
615 <option value="left">
616 <?php esc_attr_e('Left'); ?>
618 <option value="center">
619 <?php esc_attr_e('Center'); ?>
621 <option value="right">
622 <?php esc_attr_e('Right'); ?>
624 <option value="none" selected>
625 <?php esc_attr_e('None'); ?>
631 <div class="setting">
633 <# if ( data.model.canEmbed ) { #>
634 <span><?php _e('Embed or Link'); ?></span>
636 <span><?php _e('Link To'); ?></span>
639 <select class="link-to"
641 <# if ( data.userSettings && ! data.model.canEmbed ) { #>
642 data-user-setting="urlbutton"
645 <# if ( data.model.canEmbed ) { #>
646 <option value="embed" selected>
647 <?php esc_attr_e('Embed Media Player'); ?>
649 <option value="file">
651 <option value="file" selected>
653 <# if ( data.model.canEmbed ) { #>
654 <?php esc_attr_e('Link to Media File'); ?>
656 <?php esc_attr_e('Media File'); ?>
659 <option value="post">
660 <# if ( data.model.canEmbed ) { #>
661 <?php esc_attr_e('Link to Attachment Page'); ?>
663 <?php esc_attr_e('Attachment Page'); ?>
666 <# if ( 'image' === data.type ) { #>
667 <option value="custom">
668 <?php esc_attr_e('Custom URL'); ?>
670 <option value="none">
671 <?php esc_attr_e('None'); ?>
676 <input type="text" class="link-to-custom" data-setting="linkUrl" />
679 <# if ( 'undefined' !== typeof data.sizes ) { #>
680 <label class="setting">
681 <span><?php _e('Size'); ?></span>
682 <select class="size" name="size"
684 <# if ( data.userSettings ) { #>
685 data-user-setting="imgsize"
688 /** This filter is documented in wp-admin/includes/media.php */
689 $sizes = apply_filters( 'image_size_names_choose', array(
690 'thumbnail' => __('Thumbnail'),
691 'medium' => __('Medium'),
692 'large' => __('Large'),
693 'full' => __('Full Size'),
696 foreach ( $sizes as $value => $name ) : ?>
698 var size = data.sizes['<?php echo esc_js( $value ); ?>'];
700 <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'full' ); ?>>
701 <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }}
710 <script type="text/html" id="tmpl-gallery-settings">
711 <h3><?php _e('Gallery Settings'); ?></h3>
713 <label class="setting">
714 <span><?php _e('Link To'); ?></span>
715 <select class="link-to"
717 <# if ( data.userSettings ) { #>
718 data-user-setting="urlbutton"
721 <option value="post" <# if ( ! wp.media.galleryDefaults.link || 'post' == wp.media.galleryDefaults.link ) {
722 #>selected="selected"<# }
724 <?php esc_attr_e('Attachment Page'); ?>
726 <option value="file" <# if ( 'file' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>>
727 <?php esc_attr_e('Media File'); ?>
729 <option value="none" <# if ( 'none' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>>
730 <?php esc_attr_e('None'); ?>
735 <label class="setting">
736 <span><?php _e('Columns'); ?></span>
737 <select class="columns" name="columns"
738 data-setting="columns">
739 <?php for ( $i = 1; $i <= 9; $i++ ) : ?>
740 <option value="<?php echo esc_attr( $i ); ?>" <#
741 if ( <?php echo $i ?> == wp.media.galleryDefaults.columns ) { #>selected="selected"<# }
743 <?php echo esc_html( $i ); ?>
749 <label class="setting">
750 <span><?php _e( 'Random Order' ); ?></span>
751 <input type="checkbox" data-setting="_orderbyRandom" />
754 <label class="setting size">
755 <span><?php _e( 'Size' ); ?></span>
756 <select class="size" name="size"
758 <# if ( data.userSettings ) { #>
759 data-user-setting="imgsize"
763 // This filter is documented in wp-admin/includes/media.php
764 $size_names = apply_filters( 'image_size_names_choose', array(
765 'thumbnail' => __( 'Thumbnail' ),
766 'medium' => __( 'Medium' ),
767 'large' => __( 'Large' ),
768 'full' => __( 'Full Size' ),
771 foreach ( $size_names as $size => $label ) : ?>
772 <option value="<?php echo esc_attr( $size ); ?>">
773 <?php echo esc_html( $label ); ?>
780 <script type="text/html" id="tmpl-playlist-settings">
781 <h3><?php _e( 'Playlist Settings' ); ?></h3>
783 <# var emptyModel = _.isEmpty( data.model ),
784 isVideo = 'video' === data.controller.get('library').props.get('type'); #>
786 <label class="setting">
787 <input type="checkbox" data-setting="tracklist" <# if ( emptyModel ) { #>
790 <# if ( isVideo ) { #>
791 <span><?php _e( 'Show Video List' ); ?></span>
793 <span><?php _e( 'Show Tracklist' ); ?></span>
797 <# if ( ! isVideo ) { #>
798 <label class="setting">
799 <input type="checkbox" data-setting="artists" <# if ( emptyModel ) { #>
802 <span><?php _e( 'Show Artist Name in Tracklist' ); ?></span>
806 <label class="setting">
807 <input type="checkbox" data-setting="images" <# if ( emptyModel ) { #>
810 <span><?php _e( 'Show Images' ); ?></span>
814 <script type="text/html" id="tmpl-embed-link-settings">
815 <label class="setting link-text">
816 <span><?php _e( 'Link Text' ); ?></span>
817 <input type="text" class="alignment" data-setting="linkText" />
819 <div class="embed-container" style="display: none;">
820 <div class="embed-preview"></div>
824 <script type="text/html" id="tmpl-embed-image-settings">
825 <div class="thumbnail">
826 <img src="{{ data.model.url }}" draggable="false" />
830 /** This filter is documented in wp-admin/includes/media.php */
831 if ( ! apply_filters( 'disable_captions', '' ) ) : ?>
832 <label class="setting caption">
833 <span><?php _e('Caption'); ?></span>
834 <textarea data-setting="caption" />
838 <label class="setting alt-text">
839 <span><?php _e('Alt Text'); ?></span>
840 <input type="text" data-setting="alt" />
843 <div class="setting align">
844 <span><?php _e('Align'); ?></span>
845 <div class="button-group button-large" data-setting="align">
846 <button class="button" value="left">
847 <?php esc_attr_e('Left'); ?>
849 <button class="button" value="center">
850 <?php esc_attr_e('Center'); ?>
852 <button class="button" value="right">
853 <?php esc_attr_e('Right'); ?>
855 <button class="button active" value="none">
856 <?php esc_attr_e('None'); ?>
861 <div class="setting link-to">
862 <span><?php _e('Link To'); ?></span>
863 <div class="button-group button-large" data-setting="link">
864 <button class="button" value="file">
865 <?php esc_attr_e('Image URL'); ?>
867 <button class="button" value="custom">
868 <?php esc_attr_e('Custom URL'); ?>
870 <button class="button active" value="none">
871 <?php esc_attr_e('None'); ?>
874 <input type="text" class="link-to-custom" data-setting="linkUrl" />
878 <script type="text/html" id="tmpl-image-details">
879 <div class="media-embed">
880 <div class="embed-media-settings">
881 <div class="column-image">
883 <img src="{{ data.model.url }}" draggable="false" />
885 <# if ( data.attachment && window.imageEdit ) { #>
886 <div class="actions">
887 <input type="button" class="edit-attachment button" value="<?php esc_attr_e( 'Edit Original' ); ?>" />
888 <input type="button" class="replace-attachment button" value="<?php esc_attr_e( 'Replace' ); ?>" />
893 <div class="column-settings">
895 /** This filter is documented in wp-admin/includes/media.php */
896 if ( ! apply_filters( 'disable_captions', '' ) ) : ?>
897 <label class="setting caption">
898 <span><?php _e('Caption'); ?></span>
899 <textarea data-setting="caption">{{ data.model.caption }}</textarea>
903 <label class="setting alt-text">
904 <span><?php _e('Alternative Text'); ?></span>
905 <input type="text" data-setting="alt" value="{{ data.model.alt }}" />
908 <h3><?php _e( 'Display Settings' ); ?></h3>
909 <div class="setting align">
910 <span><?php _e('Align'); ?></span>
911 <div class="button-group button-large" data-setting="align">
912 <button class="button" value="left">
913 <?php esc_attr_e('Left'); ?>
915 <button class="button" value="center">
916 <?php esc_attr_e('Center'); ?>
918 <button class="button" value="right">
919 <?php esc_attr_e('Right'); ?>
921 <button class="button active" value="none">
922 <?php esc_attr_e('None'); ?>
927 <# if ( data.attachment ) { #>
928 <# if ( 'undefined' !== typeof data.attachment.sizes ) { #>
929 <label class="setting size">
930 <span><?php _e('Size'); ?></span>
931 <select class="size" name="size"
933 <# if ( data.userSettings ) { #>
934 data-user-setting="imgsize"
937 /** This filter is documented in wp-admin/includes/media.php */
938 $sizes = apply_filters( 'image_size_names_choose', array(
939 'thumbnail' => __('Thumbnail'),
940 'medium' => __('Medium'),
941 'large' => __('Large'),
942 'full' => __('Full Size'),
945 foreach ( $sizes as $value => $name ) : ?>
947 var size = data.sizes['<?php echo esc_js( $value ); ?>'];
949 <option value="<?php echo esc_attr( $value ); ?>">
950 <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }}
954 <option value="<?php echo esc_attr( 'custom' ); ?>">
955 <?php _e( 'Custom Size' ); ?>
960 <div class="custom-size<# if ( data.model.size !== 'custom' ) { #> hidden<# } #>">
961 <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>
965 <div class="setting link-to">
966 <span><?php _e('Link To'); ?></span>
967 <select data-setting="link">
968 <# if ( data.attachment ) { #>
969 <option value="file">
970 <?php esc_attr_e('Media File'); ?>
972 <option value="post">
973 <?php esc_attr_e('Attachment Page'); ?>
976 <option value="file">
977 <?php esc_attr_e('Image URL'); ?>
980 <option value="custom">
981 <?php esc_attr_e('Custom URL'); ?>
983 <option value="none">
984 <?php esc_attr_e('None'); ?>
987 <input type="text" class="link-to-custom" data-setting="linkUrl" />
989 <div class="advanced-section">
990 <h3><a class="advanced-toggle" href="#"><?php _e('Advanced Options'); ?></a></h3>
991 <div class="advanced-settings hidden">
992 <div class="advanced-image">
993 <label class="setting title-text">
994 <span><?php _e('Image Title Attribute'); ?></span>
995 <input type="text" data-setting="title" value="{{ data.model.title }}" />
997 <label class="setting extra-classes">
998 <span><?php _e('Image CSS Class'); ?></span>
999 <input type="text" data-setting="extraClasses" value="{{ data.model.extraClasses }}" />
1002 <div class="advanced-link">
1003 <div class="setting link-target">
1004 <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>
1006 <label class="setting link-rel">
1007 <span><?php _e('Link Rel'); ?></span>
1008 <input type="text" data-setting="linkRel" value="{{ data.model.linkClassName }}" />
1010 <label class="setting link-class-name">
1011 <span><?php _e('Link CSS Class'); ?></span>
1012 <input type="text" data-setting="linkClassName" value="{{ data.model.linkClassName }}" />
1022 <script type="text/html" id="tmpl-image-editor">
1023 <div id="media-head-{{ data.id }}"></div>
1024 <div id="image-editor-{{ data.id }}"></div>
1027 <script type="text/html" id="tmpl-audio-details">
1028 <# var ext, html5types = {
1029 mp3: wp.media.view.settings.embedMimes.mp3,
1030 ogg: wp.media.view.settings.embedMimes.ogg
1033 <?php $audio_types = wp_get_audio_extensions(); ?>
1034 <div class="media-embed media-embed-details">
1035 <div class="embed-media-settings embed-audio-settings">
1036 <?php wp_underscore_audio_template() ?>
1038 <# if ( ! _.isEmpty( data.model.src ) ) {
1039 ext = data.model.src.split('.').pop();
1040 if ( html5types[ ext ] ) {
1041 delete html5types[ ext ];
1044 <label class="setting">
1046 <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" />
1047 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1052 foreach ( $audio_types as $type ):
1053 ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) {
1054 if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) {
1055 delete html5types.<?php echo $type ?>;
1058 <label class="setting">
1059 <span><?php echo strtoupper( $type ) ?></span>
1060 <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" />
1061 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1066 <# if ( ! _.isEmpty( html5types ) ) { #>
1067 <div class="setting">
1068 <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ) ?></span>
1069 <div class="button-large">
1070 <# _.each( html5types, function (mime, type) { #>
1071 <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button>
1077 <div class="setting preload">
1078 <span><?php _e( 'Preload' ); ?></span>
1079 <div class="button-group button-large" data-setting="preload">
1080 <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button>
1081 <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button>
1082 <button class="button active" value="none"><?php _e( 'None' ); ?></button>
1086 <label class="setting checkbox-setting">
1087 <input type="checkbox" data-setting="autoplay" />
1088 <span><?php _e( 'Autoplay' ); ?></span>
1091 <label class="setting checkbox-setting">
1092 <input type="checkbox" data-setting="loop" />
1093 <span><?php _e( 'Loop' ); ?></span>
1099 <script type="text/html" id="tmpl-video-details">
1100 <# var ext, html5types = {
1101 mp4: wp.media.view.settings.embedMimes.mp4,
1102 ogv: wp.media.view.settings.embedMimes.ogv,
1103 webm: wp.media.view.settings.embedMimes.webm
1106 <?php $video_types = wp_get_video_extensions(); ?>
1107 <div class="media-embed media-embed-details">
1108 <div class="embed-media-settings embed-video-settings">
1109 <div class="wp-video-holder">
1111 var w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width,
1112 h = ! data.model.height ? 360 : data.model.height;
1114 if ( data.model.width && w !== data.model.width ) {
1115 h = Math.ceil( ( h * w ) / data.model.width );
1119 <?php wp_underscore_video_template() ?>
1121 <# if ( ! _.isEmpty( data.model.src ) ) {
1122 ext = data.model.src.split('.').pop();
1123 if ( html5types[ ext ] ) {
1124 delete html5types[ ext ];
1127 <label class="setting">
1129 <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" />
1130 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1133 <?php foreach ( $video_types as $type ):
1134 ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) {
1135 if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) {
1136 delete html5types.<?php echo $type ?>;
1139 <label class="setting">
1140 <span><?php echo strtoupper( $type ) ?></span>
1141 <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" />
1142 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1148 <# if ( ! _.isEmpty( html5types ) ) { #>
1149 <div class="setting">
1150 <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ); ?></span>
1151 <div class="button-large">
1152 <# _.each( html5types, function (mime, type) { #>
1153 <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button>
1159 <# if ( ! _.isEmpty( data.model.poster ) ) { #>
1160 <label class="setting">
1161 <span><?php _e( 'Poster Image' ); ?></span>
1162 <input type="text" disabled="disabled" data-setting="poster" value="{{ data.model.poster }}" />
1163 <a class="remove-setting"><?php _e( 'Remove' ); ?></a>
1166 <div class="setting preload">
1167 <span><?php _e( 'Preload' ); ?></span>
1168 <div class="button-group button-large" data-setting="preload">
1169 <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button>
1170 <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button>
1171 <button class="button active" value="none"><?php _e( 'None' ); ?></button>
1175 <label class="setting checkbox-setting">
1176 <input type="checkbox" data-setting="autoplay" />
1177 <span><?php _e( 'Autoplay' ); ?></span>
1180 <label class="setting checkbox-setting">
1181 <input type="checkbox" data-setting="loop" />
1182 <span><?php _e( 'Loop' ); ?></span>
1185 <label class="setting" data-setting="content">
1186 <span><?php _e( 'Tracks (subtitles, captions, descriptions, chapters, or metadata)' ); ?></span>
1189 if ( ! _.isEmpty( data.model.content ) ) {
1190 var tracks = jQuery( data.model.content ).filter( 'track' );
1191 _.each( tracks.toArray(), function (track) {
1192 content += track.outerHTML; #>
1194 <input class="content-track" type="text" value="{{ track.outerHTML }}" />
1195 <a class="remove-setting remove-track"><?php _e( 'Remove' ); ?></a>
1199 <em><?php _e( 'There are no associated subtitles.' ); ?></em>
1201 <textarea class="hidden content-setting">{{ content }}</textarea>
1207 <script type="text/html" id="tmpl-editor-gallery">
1208 <# if ( data.attachments.length ) { #>
1209 <div class="gallery gallery-columns-{{ data.columns }}">
1210 <# _.each( data.attachments, function( attachment, index ) { #>
1211 <dl class="gallery-item">
1212 <dt class="gallery-icon">
1213 <# if ( attachment.thumbnail ) { #>
1214 <img src="{{ attachment.thumbnail.url }}" width="{{ attachment.thumbnail.width }}" height="{{ attachment.thumbnail.height }}" />
1216 <img src="{{ attachment.url }}" />
1219 <# if ( attachment.caption ) { #>
1220 <dd class="wp-caption-text gallery-caption">
1221 {{ attachment.caption }}
1225 <# if ( index % data.columns === data.columns - 1 ) { #>
1226 <br style="clear: both;">
1231 <div class="wpview-error">
1232 <div class="dashicons dashicons-format-gallery"></div><p><?php _e( 'No items found.' ); ?></p>
1237 <script type="text/html" id="tmpl-crop-content">
1238 <img class="crop-image" src="{{ data.url }}">
1239 <div class="upload-errors"></div>
1245 * Fires when the custom Backbone media templates are printed.
1249 do_action( 'print_media_templates' );