From 2c67dea9bcbfda67f7f3d6f6a9ce8159a1bae911 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 23 Jul 2013 05:39:08 +0000 Subject: [PATCH] Media: Add awareness to Attachment Display Settings that audio and video can be embedded. Also: * Add file length metadata to Attachment Details. * Round the kb/s bitrate on post.php. fixes #24449. git-svn-id: http://core.svn.wordpress.org/trunk@24777 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/media.php | 2 +- wp-includes/js/media-editor.js | 95 ++++++++-------------------------- wp-includes/js/media-views.js | 19 ++++++- wp-includes/media-template.php | 39 ++++++++++++-- wp-includes/media.php | 6 +++ 5 files changed, 82 insertions(+), 79 deletions(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 0f784868ac..42ca1e2d6c 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -2470,7 +2470,7 @@ function attachment_submitbox_metadata() { if ( ! empty( $meta['bitrate'] ) ) : ?>
<# } #> + <# if ( data.fileLength ) { #> +
{{ data.fileLength }}
+ <# } #> + <# if ( ! data.uploading && data.can.remove ) { #> <# } #> @@ -281,25 +285,52 @@ function wp_print_media_templates() {
diff --git a/wp-includes/media.php b/wp-includes/media.php index 1362f78bbb..9b5d6a8cc1 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1699,6 +1699,11 @@ function wp_prepare_attachment_for_js( $attachment ) { $response['height'] = (int) $meta['height']; } + if ( $meta && ( 'audio' === $type || 'video' === $type ) ) { + if ( isset( $meta['length_formatted'] ) ) + $response['fileLength'] = $meta['length_formatted']; + } + if ( function_exists('get_compat_media_markup') ) $response['compat'] = get_compat_media_markup( $attachment->ID, array( 'in_modal' => true ) ); @@ -1753,6 +1758,7 @@ function wp_enqueue_media( $args = array() ) { 'id' => 0, ), 'defaultProps' => $props, + 'embedExts' => array_merge( wp_get_audio_extensions(), wp_get_video_extensions() ), ); $post = null;