|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/nlyfoods/js/ |
Upload File : |
// By Chris Coyier & tweaked by Mathias Bynens, Rob G (Mottie)
$(function() {
// Find videos
var $allVideos = $("iframe[src^='http://player.vimeo.com'], iframe[src^='http://www.youtube.com'], object, embed"),
// The element that is fluid width
$fluidEl = $(".video");
// Figure out and save aspect ratio for each video
$allVideos.each(function() {
$(this).data('aspectRatio', this.height / this.width)
// and remove the hard coded height
.removeAttr('height')
// set width to 100% of its container
.attr('width', '100%');
});
// When the window is resized
// (You'll probably want to debounce this)
$(window).resize(function() {
// Resize all videos according to their own aspect ratio
$allVideos.each(function() {
var $el = $(this);
$el.height($fluidEl.width() * $el.data('aspectRatio'));
});
// Kick off one resize to fix all videos on page load
}).resize();
});