Skip to content

Instantly share code, notes, and snippets.

@epierpont
Created March 9, 2015 16:46
Show Gist options
  • Save epierpont/b5c07627a3c2aedb527e to your computer and use it in GitHub Desktop.
Save epierpont/b5c07627a3c2aedb527e to your computer and use it in GitHub Desktop.
WP - Wrap class around videos
.video-container {
width: 100%;
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
<?php
// responsive video embed
add_filter( 'embed_oembed_html', 'custom_oembed_filter', 10, 4 );
function custom_oembed_filter( $html, $url, $attr, $post_ID ) {
$video_wrap = '<div class="video-container">' . $html . '</div>';
return $video_wrap;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment