PageRenderTime 57ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-includes/media-template.php

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