diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php
index f4b043dba2..f1ba77f5d7 100644
--- a/wp-admin/includes/ajax-actions.php
+++ b/wp-admin/includes/ajax-actions.php
@@ -2705,7 +2705,9 @@ function wp_ajax_parse_embed() {
) );
}
- wp_send_json_success( $parsed );
+ wp_send_json_success( array(
+ 'body' => $parsed
+ ) );
}
function wp_ajax_parse_media_shortcode() {
@@ -2729,19 +2731,21 @@ function wp_ajax_parse_media_shortcode() {
) );
}
- ob_start();
-
+ $head = '';
$styles = wpview_media_sandbox_styles();
- foreach ( $styles as $style ) {
- printf( '', $style );
- }
- echo $shortcode;
+ foreach ( $styles as $style ) {
+ $head .= '';
+ }
if ( ! empty( $wp_scripts ) ) {
$wp_scripts->done = array();
}
+ ob_start();
+
+ echo $shortcode;
+
if ( 'playlist' === $_REQUEST['type'] ) {
wp_underscore_playlist_templates();
@@ -2750,5 +2754,8 @@ function wp_ajax_parse_media_shortcode() {
wp_print_scripts( 'wp-mediaelement' );
}
- wp_send_json_success( ob_get_clean() );
+ wp_send_json_success( array(
+ 'head' => $head,
+ 'body' => ob_get_clean()
+ ) );
}
diff --git a/wp-includes/js/mce-view.js b/wp-includes/js/mce-view.js
index a5b1806af4..1632d7daba 100644
--- a/wp-includes/js/mce-view.js
+++ b/wp-includes/js/mce-view.js
@@ -123,16 +123,35 @@ window.wp = window.wp || {};
} );
},
/* jshint scripturl: true */
- setIframes: function ( html ) {
- var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
+ setIframes: function ( head, body ) {
+ var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,
+ importStyles = this.type === 'video' || this.type === 'audio' || this.type === 'playlist';
- if ( html.indexOf( '