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
This commit is contained in:
parent
d8310e4c7e
commit
610c593fda
|
@ -462,9 +462,12 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
canEmbed: function( attachment ) {
|
canEmbed: function( attachment ) {
|
||||||
var type = attachment.get('type');
|
// If uploading, we know the filename but not the mime type.
|
||||||
if ( type !== 'audio' && type !== 'video' )
|
if ( ! attachment.get('uploading') ) {
|
||||||
return false;
|
var type = attachment.get('type');
|
||||||
|
if ( type !== 'audio' && type !== 'video' )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return _.contains( media.view.settings.embedExts, attachment.get('filename').split('.').pop() );
|
return _.contains( media.view.settings.embedExts, attachment.get('filename').split('.').pop() );
|
||||||
},
|
},
|
||||||
|
|
|
@ -297,14 +297,9 @@ function wp_print_media_templates() {
|
||||||
data-user-setting="urlbutton"
|
data-user-setting="urlbutton"
|
||||||
<# } #>>
|
<# } #>>
|
||||||
|
|
||||||
<# if ( data.model.canEmbed && 'audio' === data.type ) { #>
|
<# if ( data.model.canEmbed ) { #>
|
||||||
<option value="embed" selected>
|
<option value="embed" selected>
|
||||||
<?php esc_attr_e('Embed Audio Player'); ?>
|
<?php esc_attr_e('Embed Media Player'); ?>
|
||||||
</option>
|
|
||||||
<option value="file">
|
|
||||||
<# } else if ( data.model.canEmbed && 'video' === data.type ) { #>
|
|
||||||
<option value="embed" selected>
|
|
||||||
<?php esc_attr_e('Embed Video Player'); ?>
|
|
||||||
</option>
|
</option>
|
||||||
<option value="file">
|
<option value="file">
|
||||||
<# } else { #>
|
<# } else { #>
|
||||||
|
|
Loading…
Reference in New Issue