Created
November 20, 2017 23:04
-
-
Save thommeredith/bbf4bcd93c1a2d65e16a122ac02a1583 to your computer and use it in GitHub Desktop.
Adds Bootstrap 3 Responsive wrap to oembed videos on Wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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