Skip to content

Instantly share code, notes, and snippets.

@thommeredith
Created November 20, 2017 23:04
Show Gist options
  • Save thommeredith/bbf4bcd93c1a2d65e16a122ac02a1583 to your computer and use it in GitHub Desktop.
Save thommeredith/bbf4bcd93c1a2d65e16a122ac02a1583 to your computer and use it in GitHub Desktop.
Adds Bootstrap 3 Responsive wrap to oembed videos on Wordpress
add_filter( 'embed_oembed_html', function ( $html, $url, $attr ) {
if ((stripos($html,'<iframe') !== false || stripos($html,'<object') !== false || stripos($html,'<embed') !== false) && stripos($html,'flex-video') === false ) {
$html = str_replace("<iframe","<iframe class='embed-responsive-item'",$html);
return '<div class="embed-responsive embed-responsive-16by9">'.$html.'</div>';
} else {
return $html;
}
}, 9999, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment