PageRenderTime 62ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-includes/media-template.php

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