Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove errant .css('height') && .css('width') checks #223

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion jquery.fitvids.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@
if($this.parents(ignoreList).length > 0) {
return; // Disable FitVids on this video.
}

if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width'))))
if ((!/height/.test($this.attr('style')) && !/width/.test($this.attr('style'))) && (isNaN($this.attr('height')) || isNaN($this.attr('width'))))
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcdarwin Are you missing an open paren on that if statement?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NM. My eyes are playing tricks on me 😬

$this.attr('height', 9);
$this.attr('width', 16);
Expand All @@ -75,6 +76,11 @@
}
$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%');
$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.
if ($this.attr('style')) {
$this.css({height: '', width: ''});
}
});
});
};
Expand Down