Skip to content

Instantly share code, notes, and snippets.

@leavlzi
Last active October 24, 2018 01:52
Show Gist options
  • Save leavlzi/dc632902bfbee814afaab2abd9d8f129 to your computer and use it in GitHub Desktop.
Save leavlzi/dc632902bfbee814afaab2abd9d8f129 to your computer and use it in GitHub Desktop.
/* Add responsive container to embeds
/* ------------------------------------ */
function alx_embed_html( $html ) {
return '<div class="video-container">' . $html . '</div>';
}
add_filter( 'embed_oembed_html', 'alx_embed_html', 10, 3 );
add_filter( 'video_embed_html', 'alx_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