Skip to content

Instantly share code, notes, and snippets.

@gnikolopoulos
Created January 7, 2016 16:22
Show Gist options
  • Save gnikolopoulos/cd14b2ab11e6d443b4de to your computer and use it in GitHub Desktop.
Save gnikolopoulos/cd14b2ab11e6d443b4de to your computer and use it in GitHub Desktop.
[Wordpress] Responsive embed videos without plugins
<?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
.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