PageRenderTime 63ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/APP/wp-includes/media-template.php

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