From ef6af221d7ebc753fad55a259a5c25b11ff80508 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 14 Mar 2014 12:20:15 +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. Built from https://develop.svn.wordpress.org/trunk@27533 git-svn-id: http://core.svn.wordpress.org/trunk@27376 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media-template.php | 154 +++++++++++++++++++++------------ 1 file changed, 97 insertions(+), 57 deletions(-) diff --git a/wp-includes/media-template.php b/wp-includes/media-template.php index 8fa9afd9d4..d8d6423725 100644 --- a/wp-includes/media-template.php +++ b/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 ) ) { #>