The frameborder
, webkitallowfullscreen
and mozallowfullscreen
are obsolete or invalid iframe
attributes and should be removed from youtube and vimeo video oEmbeds. WordPress automatically adds these attributes with video oembeds from popular sites like vimeo and youtube.
Use CSS to remove any border
styling from iframes.
You can use this function in your WordPress theme’s functions.php file to ensure your iframe code for vimeo or youtube video oEmbeds are valid.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
// customize oembed code to remove invalid attributes function mix_validate_oembed($code){ if(strpos($code, 'youtu.be') !== false || strpos($code, 'youtube.com') !== false || strpos($code, 'vimeo.com')){ // Remove the unwanted attributes: $return = str_ireplace( array( 'frameborder="0"', 'webkitallowfullscreen', 'mozallowfullscreen' ), '', $code ); return $return; } return $code; } add_filter('embed_handler_html', 'mix_validate_oembed'); add_filter('embed_oembed_html', 'mix_validate_oembed'); |