From 4a2ffa917ccab29a28b3abb662e9f26af96a0053 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 14 Mar 2014 12:19:40 +0000 Subject: [PATCH] When rendering Underscore templates for Audio/Video details, use 2 new PHP functions to render the markup for audio and video tags: `wp_underscore_audio_template()` and `wp_underscore_video_template()`. Future JS templates can follow the convention of expecting `data` to be passed to them containing a `model` property. See #27389. git-svn-id: https://develop.svn.wordpress.org/trunk@27533 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/media-template.php | 154 ++++++++++++++++++----------- 1 file changed, 97 insertions(+), 57 deletions(-) diff --git a/src/wp-includes/media-template.php b/src/wp-includes/media-template.php index 8fa9afd9d4..d8d6423725 100644 --- a/src/wp-includes/media-template.php +++ b/src/wp-includes/media-template.php @@ -7,6 +7,99 @@ * @since 3.5.0 */ +/** + * Output the markup for a audio tag to be used in an Underscore template + * when data.model is passed. + * + * @since 3.9.0 + */ +function wp_underscore_audio_template() { + $audio_types = wp_get_audio_extensions(); +?> + + +<# +var isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/); + w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width, + h = ! data.model.height ? 360 : data.model.height; + +if ( data.model.width && w !== data.model.width ) { + h = Math.ceil( ( h * w ) / data.model.width ); +} +#> +
+ +
+
{{{ wp.media.view.l10n.audioDetailsText }}}
- + + <# if ( ! _.isEmpty( data.model.src ) ) { #>