• I am trying to figure out if it is possible for the [embed][/embed] shortcode feature on WordPress to display a title within the iframe?

    When inspecting the youtube video once it is being displayed on the page, it appears like:

    <iframe width=”940″ height=”529″ src=”https://www.youtube.com/embed/xLZvgt_bPwE?feature=oembed&#8221; frameborder=”0″ allowfullscreen=””></iframe>

    Would there be a way to edit the embed feature to also include a title (ex: <iframe width="940" height="529" title="Youtube Video" src="https://www.youtube.com/embed/xLZvgt_bPwE?feature=oembed" frameborder="0" allowfullscreen=""></iframe> once it is displayed on the page or post?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Add this to your child theme’s functions file after modification:

    add_filter('embed_handler_html', function( $html ) {
    
    	$title = 'YouTube Video';
    
    	return str_replace(
    		'src=',
    		'title="' . $title . '" src=',
    		$html
    	);
    
    });
    Thread Starter rkim

    (@rkim)

    Thanks Samuel! However this doesn’t seem to be working?

    We are also using the oembed_filter to insert the youtube links onto our pages/posts:

    function oembed_filter( $html ) {
    	return '<figure class="video-container">' . $html . '</figure>';
    }

    Would you say this will be in conflict with the code snippet given?

    Also is there a way to grab the actual title of the youtube video and have that be set as the $title variable? Since we do house multiple videos across our site.

    Hi,

    Can you fix this problem? I’m interesting by accesibility

    Thanks!!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Possible to edit [embed][/embed] shortcode output to include title?’ is closed to new replies.