Remove frameborder attribute from iframes
The W3C Validator outputs an error because Wordpress adds frameborder="0"
to iframes. Also the Validator does not like the allow attribute.
I found a similar question for Vimeo Videos: WordPress oEmbed W3C Validation. However, I couldn't get it to work.
That's the code I added to the function.php file which however does not work:
add_filter( 'oembed_dataparse', function( $return, $data, $url )
{
if( is_object( $data ) )
{
// Remove the unwanted attributes:
$return = str_ireplace(
array(
'frameborder="0"'
),
'',
$return
);
}
return $return;
}, 10, 3 );
That's what the source code fragment looks like:
iframe width="500" height="281" src="https://www.youtube.com/embed/qUi422H0sx0?feature=oembed" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen
And does anyone know for the second error with allow
: Can it be just removed like the frameborder or is there an html5 version of it?
Topic validation oembed theme-development html5 Wordpress
Category Web