Created
January 7, 2016 16:22
-
-
Save gnikolopoulos/cd14b2ab11e6d443b4de to your computer and use it in GitHub Desktop.
[Wordpress] Responsive embed videos without plugins
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
<?php | |
/* Add responsive container to embeds | |
/* ------------------------------------ */ | |
function id_embed_html( $html ) { | |
return '<div class="video-container">' . $html . '</div>'; | |
} | |
add_filter( 'embed_oembed_html', 'id_embed_html', 10, 3 ); | |
add_filter( 'video_embed_html', 'id_embed_html' ); // Jetpack |
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
.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