When I insert youtube video in my post by just putting the link(http://youtu.be/KvtkknNawCQ).
The video aspect ratio becomes 4:3.
How can I change to 16:9?
1 comment
Comments are closed.
When I insert youtube video in my post by just putting the link(http://youtu.be/KvtkknNawCQ).
The video aspect ratio becomes 4:3.
How can I change to 16:9?
Comments are closed.
WordPress does a pretty good job of embedding videos at the correct aspect ratio. The width of the embedded video is based on the content width set in your theme’s functions.php file. Because of this it sounds as if there may be some styles applied to the iframe element in your theme changing it’s size.
To ensure that your videos work at any width within a responsive layout without getting unsightly black borders around the video you’ll need to take a few extra steps.
First you’ll need to wrap the embedded video in a div so that we can apply some styles to it. Add the following to your functions.php file.
Next we’re going to add some styles that setup an intrinsic ratio ensuring the height of the video scales proportionally when the width changes.
The .video:before element uses padding to set it’s height relative to it’s parent, the .video div. 56.25% is the 16:9 ratio worked out by dividing 9 by 16.
If you need to handle any aspect ratio dynamically, you can skip the above steps and use a jQuery plugin like FitVids.