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: http://core.svn.wordpress.org/trunk@24784 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-07-23 17:29:55 +00:00
parent 60c9de28b4
commit 622709076b
2 changed files with 8 additions and 10 deletions

View File

@ -462,9 +462,12 @@
},
canEmbed: function( attachment ) {
// 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() );
},

View File

@ -297,14 +297,9 @@ function wp_print_media_templates() {
data-user-setting="urlbutton"
<# } #>>
<# if ( data.model.canEmbed && 'audio' === data.type ) { #>
<# if ( data.model.canEmbed ) { #>
<option value="embed" selected>
<?php esc_attr_e('Embed Audio Player'); ?>
</option>
<option value="file">
<# } else if ( data.model.canEmbed && 'video' === data.type ) { #>
<option value="embed" selected>
<?php esc_attr_e('Embed Video Player'); ?>
<?php esc_attr_e('Embed Media Player'); ?>
</option>
<option value="file">
<# } else { #>