/** * YouTube Embedded Video Resizer * Version 1.01 * * Written by Trevor Fitzgerald * http://trevorfitzgerald.com/ * * This jQuery plugin will automatically resize all of * your YouTube video embeds to fill their container's * width. The width-height proportion will be maintained. * * --- * * Copyright (c) 2009 Trevor Fitzgerald (trevorfitzgerald.com) * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * */ (function($){ $.youtubeResize = function() { $('embed').each(function(){ sizeRatio = $(this).attr('width') / $(this).attr('height'); newWidth = $(this).parent().parent().width(); newHeight = Math.round(newWidth / sizeRatio); $(this) .attr('width', newWidth) .attr('height', newHeight) .parent() .attr('width', newWidth) .attr('height', newHeight); }); }; })(jQuery);