Skip to content

Instantly share code, notes, and snippets.

@tommymarshall
Created April 22, 2014 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommymarshall/11184530 to your computer and use it in GitHub Desktop.
Save tommymarshall/11184530 to your computer and use it in GitHub Desktop.
Set Video Dimensions
setVideoDimensions: function() {
var $wrapper = $('.video-wrapper');
var $video = $('.video');
var height = $wrapper.height();
var width = $wrapper.width();
// Maintain 16 / 9 aspect ratio
if (width / height > 16 / 9) {
newWidth = height / 9 * 16;
newHeight = height;
} else {
newWidth = width;
newHeight = width * 9 / 16;
}
$video.css({
height: newHeight,
width: newWidth
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment