Skip to content

Instantly share code, notes, and snippets.

@webhasan
Created April 18, 2016 03:57
Show Gist options
  • Save webhasan/3494a82cd0d05de1e34c36d16e45c5a6 to your computer and use it in GitHub Desktop.
Save webhasan/3494a82cd0d05de1e34c36d16e45c5a6 to your computer and use it in GitHub Desktop.
videoResponsive: function() {
var vidHeight,
vidWidth;
function videoRatio() {
if(window.innerWidth < 768 ) {
vidWidth = window.innerWidth - 30;
vidHeight = Math.round(9 / 16 * vidWidth );
}else if(window.innerWidth < 993 ) {
vidWidth = 720;
vidHeight = 405;
}else {
vidWidth = 940;
vidHeight = 529;
}
$('.video-popup').each(function(){
var vidLink = $(this).attr('href');
$(this).attr('href',vidLink + '?width='+vidWidth+'&height='+vidHeight+'');
});
}
videoRatio();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment