Skip to content

Commit

Permalink
added ability to specify maxWidth beyond which a video does not grow …
Browse files Browse the repository at this point in the history
…(added upstream changes from PR davatron5000#19)
  • Loading branch information
Fabian Fetik committed Oct 5, 2015
1 parent 4633291 commit 13ae3a1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion jquery.fitvids.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
$.fn.fitVids = function( options ) {
var settings = {
customSelector: null,
ignore: null
ignore: null,
maxWidth: false,
maxWidthDefault: 900
};

if(!document.getElementById('fit-vids-style')) {
Expand Down Expand Up @@ -75,6 +77,9 @@
$this.attr('id', videoID);
}
$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%');
if (settings.maxWidth && (width || settings.maxWidthDefault)) {
$this.parent('.fluid-width-video-wrapper').wrap('<div class="max-width-video-wrapper"></div>').parent('.max-width-video-wrapper').css('max-width', width ? width + "px" : settings.maxWidthDefault + "px");
}
$this.removeAttr('height').removeAttr('width');
// Now that we've used any height/width (typically specified in px) in the style attribute
// to make this iframe responsive, remove the height/width as they'd otherwise contrain the iframe.
Expand Down

0 comments on commit 13ae3a1

Please sign in to comment.