media-template.php 56 KB

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