Skip to content

Instantly share code, notes, and snippets.

@christophercochran
Created July 24, 2012 14:08
Show Gist options
  • Save christophercochran/3170083 to your computer and use it in GitHub Desktop.
Save christophercochran/3170083 to your computer and use it in GitHub Desktop.
Wrap oembeds with containing div and according styles for fluid videos in responsive design
/* OEMBED
-------------------- */
.oembed-container {
position: relative;
height: 0;
margin-top: 1em;
padding-bottom: 56.25%;
overflow: hidden;
}
.oembed-container iframe,
.oembed-container object,
.oembed-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
add_filter( 'oembed_dataparse', 'zero_embed_wrapper', 90, 3 );
/**
* Filters output of oembed to wrap with a div to help with fluid video embeds.
*
* @since zero 0.5.1
*/
function zero_embed_wrapper( $output, $data, $url ) {
return '<div class="oembed-container">' . $output . '</div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment