# Image preview gets cut off

**URL:** https://meta.discourse.org/t/image-preview-gets-cut-off/277836
**Category:** Support
**Created:** [September 5, 2023, 8:10am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836 "2023-09-05T08:10:22Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![FroggyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/froggyc/32/173038_2.png) [@FroggyC](https://meta.discourse.org/u/FroggyC)
#### Post date: [September 5, 2023, 8:10am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/1 "2023-09-05T08:10:22Z")

</div>

This seems to happen only on one of my forums and not the other, for some reason, despite both being close to the same version of Discourse.

Since a recent update, when images are embedded in posts, the lightbox thumbnail cuts off the sides of the image. This makes it really difficult to read the pictures if they have text.

It doesn’t seem to me like this is desired behavior, and in fact, it’s not happening here on Meta.

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/1/7/917eb8d499be531d80513f86387e3af68a32dca2.jpeg)

Full image

 ![](https://global.discourse-cdn.com/meta/original/4X/9/a/a/9aaca7a7505f5d1e76ddab1d2011cd4fd04bddfa.jpeg)

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [September 5, 2023, 8:43am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/2 "2023-09-05T08:43:17Z")

</div>

> [@FroggyC](#):
>
> it’s not happening here on Meta.

Hi @FroggyC 🙂

Then it’s probably because of their files settings, such as:

- **max image width** : Maximum thumbnail width of images in a post. Images with a larger width will be resized and lightboxed.

- **max image height** : Maximum thumbnail height of images in a post. Images with a larger height will be resized and lightboxed.

- **min ratio to crop** : Ratio used to crop tall images. Enter the result of width / height.

* * *

I may have read a bit too quickly.

Did the image appear correctly before the update?

If you right-click → Open image in new tab, does the image appear complete?

What settings have not their default value in settings → files?

---

<div class="post-metadata">

### Author: ![FroggyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/froggyc/32/173038_2.png) [@FroggyC](https://meta.discourse.org/u/FroggyC)
#### Post date: [September 5, 2023, 12:50pm UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/5 "2023-09-05T12:50:29Z")

</div>

All of those settings are at their defaults.

The image is not cropped when opened.

 ![image](https://global.discourse-cdn.com/meta/original/4X/f/c/e/fce147294ae77c2b92574b676181a229b2d9d622.png)  
 ![image](https://global.discourse-cdn.com/meta/original/4X/8/0/6/806d451ff93cff67bf0e8e4e35ef19ec6108c5e5.png)

I’ve tried restoring the site backup on a new instance, and that also didn’t solve the problem. So it’s obviously a configuration problem, although I honestly don’t know what.

---

<div class="post-metadata">

### Author: ![FroggyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/froggyc/32/173038_2.png) [@FroggyC](https://meta.discourse.org/u/FroggyC)
#### Post date: [September 9, 2023, 5:43pm UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/6 "2023-09-09T17:43:12Z")

</div>

Does anyone have a solution for this? I’m at my wits’ end with this problem.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [September 9, 2023, 9:02pm UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/7 "2023-09-09T21:02:14Z")

</div>

Try visiting the site in [safe mode](https://meta.discourse.org/t/53504?silent=true) to see if that makes a difference.

If the image is in a public post, share a link to it here. Maybe someone will be able to figure out what’s going on.

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [September 10, 2023, 7:24am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/8 "2023-09-10T07:24:47Z")

</div>

Hello 👋

I checked the site and it seems there is no custom css or other customization which affect the thumbnails.

This should be a site setting misconfiguration like:

> [@Canapin](#):
>
> - **min ratio to crop** : Ratio used to crop tall images. Enter the result of width / height.

But you said:

> [@FroggyC](#):
>
> All of those settings are at their defaults.

By the way what is the default value on your `min ratio to crop` setting?

* * *

Maybe a CDN misconfiguration? If you use a cloud based image resizer to optimized images (thumbnails). This is not very likely but this could be also a possible reason.

* * *

An other possible reason is a plugin which can do things with thumbnails. As Simon suggested you can also try upload new images in [safe mode](https://meta.discourse.org/t/53504?silent=true) to check this might caused by a plugin. (but as I saw, you don’t use such a plugin.) If I am wrong and you use any plugin like this, sometimes disables the plugin on admin is not enough, in this case you have to comment out (remove) from `app.yml` and try again…

But note that: These thumbnails are cooked in these sizes and cropped in posts. So if you change anything it won’t affect the existing thumbnails until you rebake the posts or resize these manually to recognize it the system as new file and generate new thumbnail for them. With new uploads these changes should show the changed result after reload the page.

> **[Campagna di Fabula Ultima](https://forum.locandagdr.it/t/campagna-di-fabula-ultima/2079/2)**
>
> Vorrei provare a fare questa campagna! Vediamo se troviamo persone.

---

<div class="post-metadata">

### Author: ![FroggyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/froggyc/32/173038_2.png) [@FroggyC](https://meta.discourse.org/u/FroggyC)
#### Post date: [September 11, 2023, 8:08am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/9 "2023-09-11T08:08:57Z")

</div>

Visited the site in [safe mode](https://meta.discourse.org/t/53504?silent=true) and the problem persists.

I also tried restoring the site on a different server with a Discourse install with the same `app.yml`, then rebaking posts, just to test if anything would change, and it didn’t.

> [@Don](#):
>
> By the way what is the default value on your `min ratio to crop` setting?

0.22, and it’s the exact same in another forum I manage that doesn’t have this problem.

> [@Don](#):
>
> Maybe a CDN misconfiguration? If you use a cloud based image resizer to optimized images (thumbnails). This is not very likely but this could be also a possible reason.

My CDN is just the basic one from Amazon AWS, and it’s with the same settings as another site that doesn’t have this problem.

> [@Don](#):
>
> An other possible reason is a plugin which can do things with thumbnails.

Unfortunately, I don’t use any plugin that would interact with that. Maybe `discourse-topic-previews-sidecar`?

---

<div class="post-metadata">

### Author: ![FroggyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/froggyc/32/173038_2.png) [@FroggyC](https://meta.discourse.org/u/FroggyC)
#### Post date: [September 11, 2023, 8:17am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/10 "2023-09-11T08:17:38Z")

</div>

I’ve checked inside my AWS S3 bucket, and it seems it’s the optimized version of the images that got cropped. So it’s some sort of bug that’s happening during image upload.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [September 11, 2023, 8:20am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/11 "2023-09-11T08:20:49Z")

</div>

Can you try :

1. Edit slightly the original picture (so it’s not recognized as an existing images by Discourse, though I’m not sure it is if you paste if from your clipboard),
2. Go to [safe mode](https://meta.discourse.org/t/53504?silent=true), everything disabled
3. Create a post
4. Paste/upload the picture
5. See if the preview or result is cropped?

🤔

This is the kind of case were everyone’s trying hard to pinpoint an issue and in the end we’ll all be “That was so obvious”, right?

![season 3 facepalm GIF](https://global.discourse-cdn.com/meta/original/4X/3/b/7/3b7468556ea32189f918fa8fd0e79319eb3bca27.webp)

---

<div class="post-metadata">

### Author: ![FroggyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/froggyc/32/173038_2.png) [@FroggyC](https://meta.discourse.org/u/FroggyC)
#### Post date: [September 11, 2023, 8:21am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/12 "2023-09-11T08:21:56Z")

</div>

I saw you writing while I posted my last update. Given my discovery on the AWS bucket, are those steps still useful?

---

<div class="post-metadata">

### Author: ![FroggyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/froggyc/32/173038_2.png) [@FroggyC](https://meta.discourse.org/u/FroggyC)
#### Post date: [September 11, 2023, 8:24am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/13 "2023-09-11T08:24:19Z")

</div>

Yeah, re-uploading the image in [safe mode](https://meta.discourse.org/t/53504?silent=true) (I took a screenshot of it, so it was slightly different) fixes the issue.

Does this mean it’s caused by a plugin?

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [September 11, 2023, 8:30am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/14 "2023-09-11T08:30:36Z")

</div>

I believe sidecar plugin has some experimental features.

Can you turn off these setting?

---

<div class="post-metadata">

### Author: ![FroggyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/froggyc/32/173038_2.png) [@FroggyC](https://meta.discourse.org/u/FroggyC)
#### Post date: [September 11, 2023, 8:34am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/15 "2023-09-11T08:34:14Z")

</div>

Not that setting, but I had the setting right under it enabled.

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/e/2/de248b879125dad6eb4e68e380753c987f50f6c2.png)

Disabling it seems to have solved the issue (at least for new pictures).

Would there be any way now to rebuild all of the optimized versions to fix the problem sitewide?

I see there’s a `uploads:regenerate_missing_optimized` rake task, but as far as I understand it would only regenerate the optimized versions that are missing.

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [September 11, 2023, 8:40am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/16 "2023-09-11T08:40:16Z")

</div>

> [@FroggyC](#):
>
> Would there be any way now to rebuild all of the optimized versions to fix the problem sitewide?

```plaintext
cd /var/discourse
./launcher enter app
rake posts:rebake

```

---

<div class="post-metadata">

### Author: ![FroggyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/froggyc/32/173038_2.png) [@FroggyC](https://meta.discourse.org/u/FroggyC)
#### Post date: [September 11, 2023, 8:42am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/17 "2023-09-11T08:42:15Z")

</div>

I thought that only rebaked the post HTML from the markdown. In any case, I’ll try it.

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [September 11, 2023, 8:47am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/18 "2023-09-11T08:47:49Z")

</div>

Yeah but I think it should regenerate because your settings changed.

---

<div class="post-metadata">

### Author: ![FroggyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/froggyc/32/173038_2.png) [@FroggyC](https://meta.discourse.org/u/FroggyC)
#### Post date: [September 11, 2023, 10:05am UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/19 "2023-09-11T10:05:37Z")

</div>

Rebaking the post hasn’t regenerated the optimized versions, unfortunately.

I’m tempted by moving the `optimized/` folder in my bucket and running `rake uploads:regenerate_missing_optimized`. Let’s see if I break everything.

Edit: Ah, but that task only works for internal storage. Not for S3.

---

<div class="post-metadata">

### Author: ![FroggyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/froggyc/32/173038_2.png) [@FroggyC](https://meta.discourse.org/u/FroggyC)
#### Post date: [September 12, 2023, 11:15pm UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/20 "2023-09-12T23:15:23Z")

</div>

In the end the offending images were few enough that I ended up manually reuploading all of them. So, the problem’s solved, although not in the most efficient manner.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [October 12, 2023, 11:15pm UTC](https://meta.discourse.org/t/image-preview-gets-cut-off/277836/21 "2023-10-12T23:15:37Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
