Image resizing doesn't seem to be working

In Discourse 2.3.0.beta3 Release Notes we are told:

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

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:

2 Likes

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

I have a fix proposed here.

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

10 Likes

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.

5 Likes

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.

8 Likes

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? :thinking:

4 Likes

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

Those dimensions demonstrate it perfectly :wink:

3 Likes

Right, but imagine that without cropping for height!

4 Likes

Thanks! You nailed the “not understanding” part perfectly! :smile:

4 Likes

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

5 Likes

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

https://github.com/discourse/discourse/pull/9224

5 Likes

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

5 Likes

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