Fix Error 153 Video player configuration error for WordPress WP_Embed Function

Issue

When you parse a Youtube link in your WordPress post, WP_embed automatically converts the link to a playable media on the front end. Due to recent changes by Google’s new policy, the embeded player might be unable to play the video properly. The error reads:

Error 153 Video player configuration error

Solution

Open your theme functions file under Appearance » Theme File Editor » Theme Functions (functions.php)

Paste the following code on the second line.


function fix_wpembed_YT_153_error( $cached_html, $url, $attr, $post_id ) {
// Ensure that the embed comes from a trusted provider like YouTube.
if ( strpos( $url, 'youtube.com' ) !== false || strpos( $url, 'youtu.be' ) !== false ) {

// Use a regular expression to find the iframe tag.
$regex = '/<iframe(.*?)>/is';

// Check if an iframe exists in the HTML.
if ( preg_match( $regex, $cached_html, $iframe_match ) ) {
$iframe_attributes = $iframe_match[1];
$new_attributes = ' referrerPolicy="strict-origin-when-cross-origin"';
$old_iframe_tag = $iframe_match[0];
$new_iframe_tag = str_replace('<iframe', "<iframe" . $new_attributes, $old_iframe_tag);
$cached_html = str_replace( $old_iframe_tag, $new_iframe_tag, $cached_html );
}
}

return $cached_html;
}

add_filter( 'embed_oembed_html', 'fix_wpembed_YT_153_error', 10, 4 );

Save and Finish. Your video should play properly like this one now. Let us know if it fixes for you. Thanks!

Today Deals!

*These special sales are shared by Glitch Deals Hero, our sister site from another neanderthal great grandfather twice removed.

Leave a Comment.

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.