Created
February 24, 2017 09:41
-
-
Save karrikas/026182c3ffd9eb2c31143bdea69adbde to your computer and use it in GitHub Desktop.
Add bootstrap responsive embed to wordpress automatic media embed and iframes
This file contains hidden or 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
<?php | |
// your custom code... | |
add_filter('embed_oembed_html', 'my_embed_oembed_html', 10, 4); | |
function my_embed_oembed_html($html, $url, $attr, $post_ID) { | |
$iframe = str_replace('<iframe', '<iframe class="embed-responsive-item"', $html); | |
$newHtml = '<div class="embed-responsive embed-responsive-16by9">%s</iframe></div>'; | |
$html = sprintf($newHtml, $iframe); | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment