Created
September 23, 2016 17:04
-
-
Save mkokes/1cc5069a0c1bbaf2d724e5d8f53b0d6f to your computer and use it in GitHub Desktop.
Responsive Video embed, filter wraps oembeds in a container and styling will make sure that it remains proportional with a flexible width
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
| // Responsive oEmbed for videos | |
| add_filter( 'embed_oembed_html', 'resp_embed', 10, 3 ); | |
| function resp_embed( $html ) { | |
| return '<div class="oembed-container">' . $html . '</div>'; | |
| } |
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
| .oembed-container { | |
| position: relative; | |
| padding-bottom: 56.25%; | |
| height: 0; | |
| overflow: hidden; | |
| } | |
| .oembed-container iframe, | |
| .oembed-container object, | |
| .oembed-container embed, | |
| .oembed-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