You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

1270 lines
45 KiB

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