# Can we get rid of height/width auto in oneboxes?

**URL:** <https://meta.discourse.org/t/can-we-get-rid-of-height-width-auto-in-oneboxes/72579>\
**Category:** UX\
**Created:** [Octobre 23, 2017, 12:52 UTC](https://meta.discourse.org/t/can-we-get-rid-of-height-width-auto-in-oneboxes/72579 "2017-10-23T00:52:50Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)\
**Post date:** [Octobre 23, 2017, 5:12 UTC](https://meta.discourse.org/t/can-we-get-rid-of-height-width-auto-in-oneboxes/72579/7 "2017-10-23T17:12:52Z")

</div>

Just tried it and it looks like you can remove height/width: auto and things work out? How are we setting height/width? Are we resizing the images proportionately when we download them? As long as we have static dimensions within our max height/width we shouldn’t need anything else.

> [@schungx](#):
>
> Probably not as an image, but as a background image, there is a setting to fit the image neatly inside the element as large as possible without cropping

Yes, CSS-defined background-image is a little nicer in this regard because you can set the container to fixed dimensions and then say `background-size: contain;` (will fit entire image to container proportionately, which may leave some white space on 2 sides).

Ultimately though, you’re not really doing much different here than if we put the images a placeholder container with static height/width. For a tall/narrow image you’d end up with whitespace on the sides of the image. We’d be losing the current functionality of reflowing the text around the image without leaving extra whitespace.

> [@codinghorror](#):
>
> I think the problem is wildly different aspect ratios.

Right, accommodating wildly different aspect ratios is tough. To stay proportionate we can only define width OR height, but one property has to be set to auto. We let one dimension hit the max-width/height, and auto-define the other. Without applying auto to the other dimension, we run into proportion issues (for example, we don’t seem to specify auto on flickr embeds?[see the stretched dog here](https://try.discourse.org/t/what-is-a-onebox/276))

> [@sam](#):
>
> Yes, we now correctly know the aspect ratio, trouble is I am not sure if you can tell CSS just to size it down to aspect giving it max-height and width without specifying some percentage.

So if I understand what you’re saying: the problem with CSS is that if you give an image a width of 120px and set a max-height of 200px — once you toss a 120px by 500px image into that box, it’ll be squished vertically.

If you know the aspect ratio of the original image you could do the math using calc() in css? You’d need some logic to determine if you should be defining or scaling height/width? You’d also be essentially supplying all the numbers to specify a percentage anyway? Maybe I’m overthinking it.

---

_[View the full topic](https://meta.discourse.org/t/can-we-get-rid-of-height-width-auto-in-oneboxes/72579)._
