From 610c593fdaa681af8de96b1bffef47b7aecca5ab Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 23 Jul 2013 17:29:55 +0000 Subject: [PATCH] Media: Fix embedding of audio/video players when the file was just uploaded. While uploading, we know an attachment's filename but not its mime type. Check specifically for extensions. Check for type as a convenience when it is available. fixes #24449. git-svn-id: https://develop.svn.wordpress.org/trunk@24784 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/js/media-views.js | 9 ++++++--- wp-includes/media-template.php | 9 ++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index 86f7472329..a14a57b042 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -462,9 +462,12 @@ }, canEmbed: function( attachment ) { - var type = attachment.get('type'); - if ( type !== 'audio' && type !== 'video' ) - return false; + // If uploading, we know the filename but not the mime type. + if ( ! attachment.get('uploading') ) { + var type = attachment.get('type'); + if ( type !== 'audio' && type !== 'video' ) + return false; + } return _.contains( media.view.settings.embedExts, attachment.get('filename').split('.').pop() ); }, diff --git a/wp-includes/media-template.php b/wp-includes/media-template.php index b5b03d6629..6af7dc5f32 100644 --- a/wp-includes/media-template.php +++ b/wp-includes/media-template.php @@ -297,14 +297,9 @@ function wp_print_media_templates() { data-user-setting="urlbutton" <# } #>> - <# if ( data.model.canEmbed && 'audio' === data.type ) { #> + <# if ( data.model.canEmbed ) { #> -