Last active
November 18, 2019 04:37
-
-
Save codyogden/07b45acd5fb79ededc164c2c76cd92a6 to your computer and use it in GitHub Desktop.
Responsive/Fluid oEmbed YouTube/Vimeo WordPress Videos
This file contains hidden or 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
/* Add responsive container to embeds | |
/* ------------------------------------ */ | |
function slug_embed_html( $html ) { | |
return '<div class="video-container">' . $html . '</div>'; | |
} | |
add_filter( 'embed_oembed_html', 'slug_embed_html', 10, 3 ); | |
add_filter( 'video_embed_html', 'slug_embed_html' ); // Jetpack |
This file contains hidden or 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
.video-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; } | |
.video-container iframe, .video-container object, .video-container embed, .video-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