Skip to content

Instantly share code, notes, and snippets.

@atomtigerzoo
Last active May 18, 2020 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save atomtigerzoo/9997cf7529cf55eb3834fed92eadb7f9 to your computer and use it in GitHub Desktop.
Save atomtigerzoo/9997cf7529cf55eb3834fed92eadb7f9 to your computer and use it in GitHub Desktop.
Wordpress: responsive oembeds - youtube, vimeo, images, etc
/*
Creates a container around embeds
*/
function responsive_embed_wrapper($content) {
return '<figure class="oembed-wrap">' . $content . '</figure>';
}
add_filter('embed_oembed_html', 'responsive_embed_wrapper', 10, 3);
/* oembed container */
.oembed-wrap{
height: 0;
margin-bottom: 1.35em;
margin-top: 1.35em;
padding-bottom: 56.25%;
position: relative;
overflow: hidden;
}
.oembed-wrap iframe,
.oembed-wrap object,
.oembed-wrap embed,
.oembed-wrap video{
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment