Created
March 15, 2015 16:02
-
-
Save besimhu/8a55a27b87b8171f9c2b to your computer and use it in GitHub Desktop.
To make videos responsive, mostly anything with <iframe> use the below function, and don’t forget to add the css as well.
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 embed videos | |
function forty_responsive_video( $html ) { | |
//add http protocol | |
$html = str_replace('<iframe src="//', '<iframe src="http://', $html); | |
return '<div class="flex-video">' . $html . '</div>'; | |
} | |
add_filter( 'embed_oembed_html', 'forty_responsive_video', 10, 3 ); | |
add_filter( 'video_embed_html', 'forty_responsive_video' ); |
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
// Make videos responsive | |
.flex-video { | |
padding-top: 0; | |
padding-bottom: 56.3%; | |
position: relative; | |
iframe { | |
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