If I were to embed a YouTube video for example
Aspect ratio is just width:height. So if you wanted to calculate the height based on a known width it is pretty straightforward.
//width=560, wanted height is 315 $('.player').parent().attr('height', 560*9/16);