[resolved] WordPress parenthesis at the end of the YouTube video (5 posts)

  1. adismet
    Posted 2 years ago #

    Hello guys!

    Since yesterday I have a strange problem with WordPress.

    Everytime I add an YouTube video on my blog, it will appear a parenthesis at the end of it.

    Source code looks like this: <p><iframe width="608" height="342" src="http://www.youtube.com/embed/lFW2vWmEShY?feature=oembed" frameborder="0" allowfullscreen></iframe>)</p>

    I didn't made any changes to my blog for a long time, so I don't really know why is this happening.

    That parenthesis doesn't show in the WP editor.

    Anyone knows how can I get rid of it?

  2. The good news is it's not you or WordPress. It's YouTube that's messed up and it's impacting embedding YouTube videos with that additional ) at the end there.

    See if this quick temporary plugin fixes it for you. It looks for </iframe>) and replaces it with just </iframe>).

    Create this file wp-content/plugins/fix-iframe.php and copy these lines into.

    Plugin Name: Remove parenthesis right after iframe
    Description: This plugin filters out the parenthesis from right after an iframe
    Author: Jan Dembowski
    add_filter( 'the_content', 'mh_fix_iframe' , 15 );
    function mh_fix_iframe( $text ) {
            // RegEx to find the right and put that into an array
            $mh_regex = "/<\/iframe>\)/";
            // Use that RegEx and populate the hits into an array
            preg_match_all( $mh_regex , $text , $mh_matches );
            // If there's any hits then loop though those and replace those hits
            for ( $mh_count = 0; $mh_count < count( $mh_matches[0] ); $mh_count++ )
                            $mh_old = $mh_matches[0][$mh_count];
                            $mh_new = str_replace( '</iframe>)' , '</iframe>' , $mh_old );
                            $text = str_replace( $mh_old  , $mh_new , $text );
            // Return any substitutions
            return $text;

    Activate the plugin and the ) should disappear from the posts.

    It's a hack and if you have other </iframes> with a ) after it (and I have no idea why you would) then that plugin might break things.

    Once YouTube fixes it you can delete that plugin.

  3. adismet
    Posted 2 years ago #

    @Jan Dembowski

    That did the trick, thank you very much!

  4. You're welcome. Hopefully YouTube will get their act together soon. ;)

    Once they do fix it then you can delete that plugin.

  5. mdidesign
    Posted 2 years ago #

    Pretty poor that it take so long for Youtube/Google to "fix" this.

Topic Closed

This topic has been closed to new replies.

About this Topic