-
Notifications
You must be signed in to change notification settings - Fork 986
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
base: master
Are you sure you want to change the base?
Conversation
iFrames have a default width (300px) and height (150px): http://stackoverflow.com/questions/5871668/default-width-height-of-an-iframe Becuase of this, .css('height') && .css('width') will return these default values, meaning that our video ends up with an aspect ratio of 2:1 rather than 16:9
Do have a CodePen of this failing? I'm fairly certain we added both the |
Yep, you can see this behaviour at: http://codepen.io/Tuscan/pen/EVNrOr The net result is that video embeds without both height and width end up On 29 September 2015 at 04:08, Dave Rupert [email protected] wrote:
|
@jcdarwin @davatron5000 Here's the convo around why we added the check: 8054992 |
Thanks for that -- for any iFrame (at least in Chrome), the condition: if ((!$this.css('height') && !$this.css('width')) && will never evaluate true, as iFrames have a default style for width (300px) Refer: http://stackoverflow.com/questions/5871668/default-width-height-of-an-iframe http://codepen.io/Tuscan/pen/EVNrOr What we really need is a way to ignore these default values -- will Jason On 30 September 2015 at 06:32, Ken Howard [email protected] wrote:
|
Had further look/think about this -- as per the amended codepen (first example in http://codepen.io/Tuscan/pen/EVNrOr) we still think there's a problem with having (!$this.css('height') && !$this.css('width'), as this means that embedded videos with no height/width end up being sized as 2:1 rather than 16:9 (because of the defaults applied to an iframe: http://stackoverflow.com/questions/5871668/default-width-height-of-an-iframe). We've also made changes to ensure that videos with height / width specified in the style attribute are also handled correctly. At the moment, fitvids will create a responsive container (with padding), but the style attribute values wil constrain the size of the video, meaning that there's a lot of whitespace (see the second example in http://codepen.io/Tuscan/pen/EVNrOr). Our change honours the aspect ratio implied by the height / width in the style attribute, and once made responsive, removes the height / width from the style attribute to ensure the video fills the container properly. |
@jcdarwin I'm ok with this latest change. Detecting that the style attribute has both a height and width is better than detecting if the element has a style and width considering the base style of an iframe. @davatron5000 You can make the final decision. |
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')))) | ||
{ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 😬
iFrames have a default width (300px) and height (150px):
http://stackoverflow.com/questions/5871668/default-width-height-of-an-iframe
Becuase of this, .css('height') && .css('width') will
return these default values, meaning that our video ends up with an
aspect ratio of 2:1 rather than 16:9