Skip to content

Instantly share code, notes, and snippets.

@mkokes
Created September 23, 2016 17:04
Show Gist options
  • Select an option

  • Save mkokes/1cc5069a0c1bbaf2d724e5d8f53b0d6f to your computer and use it in GitHub Desktop.

Select an option

Save mkokes/1cc5069a0c1bbaf2d724e5d8f53b0d6f to your computer and use it in GitHub Desktop.
Responsive Video embed, filter wraps oembeds in a container and styling will make sure that it remains proportional with a flexible width
// Responsive oEmbed for videos
add_filter( 'embed_oembed_html', 'resp_embed', 10, 3 );
function resp_embed( $html ) {
return '<div class="oembed-container">' . $html . '</div>';
}
.oembed-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
}
.oembed-container iframe,
.oembed-container object,
.oembed-container embed,
.oembed-container video {
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