# Image resizing doesn't seem to be working

**URL:** https://meta.discourse.org/t/image-resizing-doesnt-seem-to-be-working/145092
**Category:** Bug
**Created:** [March 21, 2020, 9:48pm UTC](https://meta.discourse.org/t/image-resizing-doesnt-seem-to-be-working/145092 "2020-03-21T21:48:44Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![southpaw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/southpaw/32/79352_2.png) [@southpaw](https://meta.discourse.org/u/southpaw)
#### Post date: [March 21, 2020, 9:48pm UTC](https://meta.discourse.org/t/image-resizing-doesnt-seem-to-be-working/145092/1 "2020-03-21T21:48:44Z")

</div>

In [Discourse 2.3.0.beta3 Release Notes](https://meta.discourse.org/t/discourse-2-3-0-beta3-release-notes/110445) we are told:

> [@Discourse 2.3.0.beta3 Release Notes](https://meta.discourse.org/t/discourse-2-3-0-beta3-release-notes/110445/1):
>
> Sometimes, users do not want images to take up the full-width of the post stream, so Discourse supports resizing images.  
> […]  
> Example:  
> `![2uvt7h|653x499,75%](upload://qbzzeogfD8Z5nRmc9EBfzFbZ1Jp.jpeg)`  
> […]  
> Example (width at 200px, auto-height):  
> `![image|655x499,200x](upload://pXpXLe1RRYOaNVm8LT5ncp03Jo4.jpeg)`

I’ve noticed recently that large images are displaying at full width, and the height is clipped.  
For example:

 ![image](https://global.discourse-cdn.com/meta/original/3X/3/8/387df86e6e0e8c202faad20e2ced8fead7d92232.png)

Markup for that image is written as:  
`![Screenshot_20200321-114212|210x500,200x](upload://r0GmIGqITPIix8sJgRqTXRNhuHA.jpeg)`

I’ve also tried  
`![Screenshot_20200321-114212|210x500,25%](upload://r0GmIGqITPIix8sJgRqTXRNhuHA.jpeg)`  
with the same full-width results.

When editing, the preview pane displays the image correctly:

 ![image](https://global.discourse-cdn.com/meta/original/3X/9/e/9e939783746ed2d1c86a413c9862b96a316e1cd5.png)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 23, 2020, 4:45am UTC](https://meta.discourse.org/t/image-resizing-doesnt-seem-to-be-working/145092/2 "2020-03-23T04:45:09Z")

</div>

Yeah our tall image cropping is a very very confusing feature.

I have a fix proposed here.

> [@\`min ratio to crop\` site setting should respect w/h ratio as defined in markdown](https://meta.discourse.org/t/min-ratio-to-crop-site-setting-should-respect-w-h-ratio-as-defined-in-markdown/138374/18):
>
> @zogstrip how do you feel about if crop cropped\_width, cropped\_height = ImageSizer.crop(original\_width, original\_height) if cropped\_width \< width width = cropped\_width img["width"] = width end if cropped\_height \< height height = cropped\_height img["height"] = height end end VS the existing: It is certainly less surprising than the current behavior and would make @awesomerobot happy, only real annoyance I can see is th…

@vinothkannans can you apply it, make sure tests pass and paste a bunch of examples here?

---

<div class="post-metadata">

### Author: ![southpaw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/southpaw/32/79352_2.png) [@southpaw](https://meta.discourse.org/u/southpaw)
#### Post date: [March 24, 2020, 2:31pm UTC](https://meta.discourse.org/t/image-resizing-doesnt-seem-to-be-working/145092/4 "2020-03-24T14:31:51Z")

</div>

> [@sam](#):
>
> very very confusing

Does this mean there’s something I’m not understanding and doing wrong? And I don’t mean that to sound defensive, at all, simply that if it’s just that it’s confusing and I’ve not understood it, I’d love to know what I need to correct.

---

<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: [March 24, 2020, 3:48pm UTC](https://meta.discourse.org/t/image-resizing-doesnt-seem-to-be-working/145092/5 "2020-03-24T15:48:48Z")

</div>

Large images are cropped based on the aspect ratio of the image as uploaded (there’s a setting called `min ratio to crop` that controls when they’re cropped)… this cropping applies even if the markdown dimensions fall below the cropping threshold.

So you’re not doing anything wrong other than being unaware of how the `min ratio to crop` threshold works (it would be a little crazy to expect everyone to understand that by simply looking at the image they’re about to upload, and the ratio setting is opaque to normal users!).

The fix being applied would ensure that the markdown dimensions are taken into consideration before cropping.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [March 25, 2020, 5:10am UTC](https://meta.discourse.org/t/image-resizing-doesnt-seem-to-be-working/145092/6 "2020-03-25T05:10:10Z")

</div>

Not doing anything wrong. Just imagine a user uploaded an image that was 3 pixels wide and 50000 pixels tall. What would the topic look like, if that image was displayed in proportion? What if the user posted that image over and over? 🤔

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [March 25, 2020, 6:57am UTC](https://meta.discourse.org/t/image-resizing-doesnt-seem-to-be-working/145092/7 "2020-03-25T06:57:34Z")

</div>

That reminds me, have been meaning to mention that super tall very narrow images really do screw up the Lightbox:

![fiddy2|0x500](https://global.discourse-cdn.com/meta/optimized/3X/7/7/775fc39709c6b161005fc4f9a0c8a2f4167e8e00_2_3x500.png)

Those dimensions demonstrate it perfectly 😉

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [March 25, 2020, 7:01am UTC](https://meta.discourse.org/t/image-resizing-doesnt-seem-to-be-working/145092/8 "2020-03-25T07:01:26Z")

</div>

Right, but imagine that _without_ cropping for height!

---

<div class="post-metadata">

### Author: ![southpaw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/southpaw/32/79352_2.png) [@southpaw](https://meta.discourse.org/u/southpaw)
#### Post date: [March 25, 2020, 11:41am UTC](https://meta.discourse.org/t/image-resizing-doesnt-seem-to-be-working/145092/9 "2020-03-25T11:41:52Z")

</div>

Thanks! You nailed the “not understanding” part perfectly! 😄

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 26, 2020, 7:35am UTC](https://meta.discourse.org/t/image-resizing-doesnt-seem-to-be-working/145092/10 "2020-05-26T07:35:28Z")

</div>

I think @nbianca fixed this issue and the fix is deployed!

---

<div class="post-metadata">

### Author: ![nbianca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nbianca/32/157984_2.png) [@nbianca](https://meta.discourse.org/u/nbianca)
#### Post date: [May 27, 2020, 8:19am UTC](https://meta.discourse.org/t/image-resizing-doesnt-seem-to-be-working/145092/11 "2020-05-27T08:19:28Z")

</div>

Yes, I merged the PR two months ago, so it should work properly now. 😊

[https://github.com/discourse/discourse/pull/9224](https://github.com/discourse/discourse/pull/9224)

---

<div class="post-metadata">

### Author: ![southpaw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/southpaw/32/79352_2.png) [@southpaw](https://meta.discourse.org/u/southpaw)
#### Post date: [May 28, 2020, 5:32am UTC](https://meta.discourse.org/t/image-resizing-doesnt-seem-to-be-working/145092/12 "2020-05-28T05:32:14Z")

</div>

Hooray, and thank you! We are now able to have lovely, full-length smartphone screenshots in our Community!

 ![image](https://global.discourse-cdn.com/meta/original/3X/5/0/50b9e2be1424c6ad01321f7c116a572b874c651d.png)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 30, 2020, 8:00am UTC](https://meta.discourse.org/t/image-resizing-doesnt-seem-to-be-working/145092/13 "2020-05-30T08:00:19Z")

</div>

This topic was automatically closed after 4 days. New replies are no longer allowed.
