I’ve come into this problem a few times while building out sites so I’ve built a quick function to automatically calculate and resize (height) videos on your blog/website. This is especially helpful on a site chalk full of videos like craiggoodwill.com. Without further ado:
function resize_video() { // this function is helpful when using a dynamit width on your iFrames for YouTube or Vimeo videos to automatically adjust the height $('.video iframe, .video object, .video embed').each(function(){ var width = $(this).width(); var vidheight = (width * 0.5625); $(this).css({height : vidheight}); }); }
Then call your function on both load and resize.
$(window).load(function(){ /* do the resize on load */ resize_video(); }); $(window).resize(function() { /* do the resize on orientation change as well */ resize_video(); });