Skip to content

Instantly share code, notes, and snippets.

@nhobi
Last active April 8, 2016 17:43
Show Gist options
  • Save nhobi/73268f0489a2245d9aed to your computer and use it in GitHub Desktop.
Save nhobi/73268f0489a2245d9aed to your computer and use it in GitHub Desktop.
Responsive WordPress oEmbeds
<?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');
.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