Skip to content

Commit

Permalink
Assign iFrame/embed ID if one does not exist
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Moore <[email protected]>
  • Loading branch information
Jonathan Moore committed Jan 27, 2012
1 parent c4855a7 commit 2182d41
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions jquery.fitvids.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
if (this.tagName.toLowerCase() == 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
var height = this.tagName.toLowerCase() == 'object' ? $this.attr('height') : $this.height(),
aspectRatio = height / $this.width();
if(!$this.attr('id')){
var videoID = 'fitvid' + Math.floor(Math.random()*999999);
$this.attr('id', videoID);
}
$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%");
$this.removeAttr('height').removeAttr('width');
});
Expand Down

0 comments on commit 2182d41

Please sign in to comment.