Last active
May 18, 2020 13:12
-
-
Save atomtigerzoo/9997cf7529cf55eb3834fed92eadb7f9 to your computer and use it in GitHub Desktop.
Wordpress: responsive oembeds - youtube, vimeo, images, etc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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