Products | Websites and Online Giving | GabrielSoft
//Blog article video resizing var $allVideos = $("#background:not(.admin) .fluid-width-video-wrapper iframe"), // The element that is fluid width $fluidEl = $(".fluid-width-video-wrapper"); // Figure out and save aspect ratio for each video $allVideos.each(function() { $(this) .data('aspectRatio', this.height / this.width) // and remove the hard coded width/height .removeAttr('height') .removeAttr('width'); }); // When the window is resized $(window).resize(function() { var newWidth = $fluidEl.width(); // Resize all videos according to their own aspect ratio $allVideos.each(function() { var $el = $(this); newWidth = $el.parent().width(); $el .width(newWidth) .height(newWidth * $el.data('aspectRatio')); }); // Kick off one resize to fix all videos on page load }).resize();
powered by GabrielSoft