Last active
April 8, 2016 17:43
-
-
Save nhobi/73268f0489a2245d9aed to your computer and use it in GitHub Desktop.
Responsive WordPress oEmbeds
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
<?php | |
function responsive_oembed_filter($markup, $url, $attr, $post_ID) { | |
return '<div class="video-container">' . $markup . '</div>'; | |
} | |
add_filter( 'embed_oembed_html', 'responsive_oembed_filter'); |
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
.video-container { | |
position: relative; | |
padding-bottom: 56.25%; | |
padding-top: 5px; | |
height: 0; | |
} | |
.video-container embed, | |
.video-container iframe, | |
.video-container object { | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment