Index: wp-includes/js/media-editor.js
===================================================================
--- wp-includes/js/media-editor.js (revision 24777)
+++ wp-includes/js/media-editor.js (working copy)
@@ -97,14 +97,30 @@
},
audio: function( props, attachment ) {
- return wp.media.string._audioVideo( 'audio', props, attachment );
+ var shortcode, html, extension;
+
+ props = wp.media.string.props( props, attachment );
+ if ( props.link !== 'embed' )
+ return wp.media.string.link( props );
+
+ shortcode = {};
+ extension = attachment.filename.split('.').pop();
+
+ // Render unsupported audio files as links.
+ if ( _.contains( wp.media.view.settings.audioExts, extension ) )
+ shortcode[extension] = attachment.url;
+ else
+ return wp.media.string.link( props );
+
+ html = wp.shortcode.string({
+ tag: 'audio',
+ attrs: shortcode
+ });
+
+ return html;
},
video: function( props, attachment ) {
- return wp.media.string._audioVideo( 'video', props, attachment );
- },
-
- _audioVideo: function( type, props, attachment ) {
var shortcode, html, extension;
props = wp.media.string.props( props, attachment );
@@ -113,25 +129,22 @@
shortcode = {};
- if ( 'video' === type ) {
- if ( attachment.width )
- shortcode.width = attachment.width;
+ if ( attachment.width )
+ shortcode.width = attachment.width;
- if ( attachment.height )
- shortcode.height = attachment.height;
- }
+ if ( attachment.height )
+ shortcode.height = attachment.height;
extension = attachment.filename.split('.').pop();
- if ( _.contains( wp.media.view.settings.embedExts, extension ) ) {
+ // Render unsupported video files as links.
+ if ( _.contains( wp.media.view.settings.videoExts, extension ) )
shortcode[extension] = attachment.url;
- } else {
- // Render unsupported audio and video files as links.
+ else
return wp.media.string.link( props );
- }
html = wp.shortcode.string({
- tag: type,
+ tag: 'video',
attrs: shortcode
});
Index: wp-includes/js/media-views.js
===================================================================
--- wp-includes/js/media-views.js (revision 24777)
+++ wp-includes/js/media-views.js (working copy)
@@ -462,11 +462,20 @@
},
canEmbed: function( attachment ) {
- var type = attachment.get('type');
- if ( type !== 'audio' && type !== 'video' )
- return false;
+ var type, ext;
+ // If uploading, we know the filename but not the mime type.
+ if ( ! attachment.get('uploading') ) {
+ type = attachment.get('type');
+ if ( type !== 'audio' && type !== 'video' )
+ return false;
+ }
- return _.contains( media.view.settings.embedExts, attachment.get('filename').split('.').pop() );
+ ext = attachment.get('filename').split('.').pop();
+ if ( _.contains( media.view.settings.audioExts, ext ) )
+ return 'audio';
+ if ( _.contains( media.view.settings.videoExts, ext ) )
+ return 'video';
+ return false;
},
syncSelection: function() {
Index: wp-includes/media-template.php
===================================================================
--- wp-includes/media-template.php (revision 24777)
+++ wp-includes/media-template.php (working copy)
@@ -297,12 +297,12 @@
data-user-setting="urlbutton"
<# } #>>
- <# if ( data.model.canEmbed && 'audio' === data.type ) { #>
+ <# if ( data.model.canEmbed === 'audio' ) { #>
Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php (revision 24777)
+++ wp-includes/media.php (working copy)
@@ -1758,7 +1758,8 @@
'id' => 0,
),
'defaultProps' => $props,
- 'embedExts' => array_merge( wp_get_audio_extensions(), wp_get_video_extensions() ),
+ 'audioExts' => wp_get_audio_extensions(),
+ 'videoExts' => wp_get_video_extensions(),
);
$post = null;