# Max image width setting cropping Youtube previews

**URL:** https://meta.discourse.org/t/max-image-width-setting-cropping-youtube-previews/163605
**Category:** Bug
**Tags:** fixed
**Created:** [September 10, 2020, 11:53am UTC](https://meta.discourse.org/t/max-image-width-setting-cropping-youtube-previews/163605 "2020-09-10T11:53:03Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![meiadeleite](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meiadeleite/32/139417_2.png) [@meiadeleite](https://meta.discourse.org/u/meiadeleite)
#### Post date: [September 10, 2020, 11:53am UTC](https://meta.discourse.org/t/max-image-width-setting-cropping-youtube-previews/163605/1 "2020-09-10T11:53:03Z")

</div>

Lately on our forum, all the embedded Youtube videos show with only half of the image preview within the video box, like so:

 ![Screen Shot 2020-09-10 at 12.47.48 PM](https://global.discourse-cdn.com/meta/original/3X/a/a/aaeb2993e75077d8dccdc8d79aaec4c6e580ed37.jpeg)

This seems to be related to the max image width setting (which we have set to 340px), as the behavior goes away when we remove that value. I didn’t expect this setting to impact videos though… Is this a bug, perhaps?

---

<div class="post-metadata">

### Author: ![mentalstring](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mentalstring/32/168934_2.png) [@mentalstring](https://meta.discourse.org/u/mentalstring)
#### Post date: [September 16, 2020, 7:31am UTC](https://meta.discourse.org/t/max-image-width-setting-cropping-youtube-previews/163605/2 "2020-09-16T07:31:37Z")

</div>

FWIW, I think the max image width shouldn’t apply for video (even if technically the preview is done with an image thumbnail). As is it it makes videos look a little broken due to the cropped preview.

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/1/a1962b01e7e277136c740ce2e37f3c66238fe088.jpeg)

As opposed to:

[![](https://global.discourse-cdn.com/meta/original/4X/9/2/9/92964fe94da992cc957d9da2a1cf665e2e055289.jpeg "From Now On [The Greatest Showman] - Welsh of the West End") ](https://www.youtube.com/watch?v=W2clQvaVCxA)

One idea would be to have a separate setting for max video width that applies to videos+thumbnails. Another possibility would be to respect the image max width on the thumbnail, but expand the video object on play. These are only suggestions — I don’t know how complex either of these ideas are to implement.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 22, 2020, 3:28pm UTC](https://meta.discourse.org/t/max-image-width-setting-cropping-youtube-previews/163605/3 "2020-10-22T15:28:48Z")

</div>

Yes, this site setting indeed affects all images, including the YouTube thumbnails.

Looks like we need to add another exception for youtube on

[https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/app/initializers/ensure-max-image-dimensions.js#L25](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/app/initializers/ensure-max-image-dimensions.js#L25)

cc @jordan.vidrine. To repro locally change the setting and refresh the page.

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [October 23, 2020, 1:42pm UTC](https://meta.discourse.org/t/max-image-width-setting-cropping-youtube-previews/163605/4 "2020-10-23T13:42:32Z")

</div>

This bug has been addressed and [a fix has been merged.](https://github.com/discourse/discourse/pull/11000) Thanks for bringing it to our attention 😄

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [November 6, 2020, 12:00am UTC](https://meta.discourse.org/t/max-image-width-setting-cropping-youtube-previews/163605/5 "2020-11-06T00:00:03Z")

</div>

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

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [December 13, 2020, 4:46pm UTC](https://meta.discourse.org/t/max-image-width-setting-cropping-youtube-previews/163605/6 "2020-12-13T16:46:53Z")

</div>



---

<div class="post-metadata">

### Author: ![mentalstring](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mentalstring/32/168934_2.png) [@mentalstring](https://meta.discourse.org/u/mentalstring)
#### Post date: [December 13, 2020, 5:11pm UTC](https://meta.discourse.org/t/max-image-width-setting-cropping-youtube-previews/163605/7 "2020-12-13T17:11:44Z")

</div>

This has been fixed on the posts (youtube thumbnail), but it still ~~crops~~ horizontally squeezes the thumbnail preview on the composer when the max image width is low:

 ![Screenshot 2020-12-13 at 17.10.12](https://global.discourse-cdn.com/meta/original/3X/0/f/0fef419fbe0f5b9561f9d97dd0b535cef3016f5a.jpeg)

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [July 6, 2021, 2:34pm UTC](https://meta.discourse.org/t/max-image-width-setting-cropping-youtube-previews/163605/9 "2021-07-06T14:34:29Z")

</div>

Thanks for reporting, are you still seeing this issue?

---

<div class="post-metadata">

### Author: ![mentalstring](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mentalstring/32/168934_2.png) [@mentalstring](https://meta.discourse.org/u/mentalstring)
#### Post date: [July 6, 2021, 6:31pm UTC](https://meta.discourse.org/t/max-image-width-setting-cropping-youtube-previews/163605/10 "2021-07-06T18:31:06Z")

</div>

I confirm this is still happening on stable. I’m afraid I don’t have a tests-passed instance at hand where I can check this right now.

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/7/a7b74db07d6a7354dcf11b9151184b7a6dd8a071.jpeg)

This is happening when `max_image_width=340`.

Once posted, the embedded video itself is fine (ie, image width doesn’t apply to the video) and that part is fixed. But while composing the message, the thumbnail preview gets squeezed. Technically an image, but I don’t think the `max_image_width` should apply here?

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [July 7, 2021, 12:04am UTC](https://meta.discourse.org/t/max-image-width-setting-cropping-youtube-previews/163605/11 "2021-07-07T00:04:04Z")

</div>

I recently worked on some changes to image sizes in the post stream (and by extension, previews), and I believe this issue is no longer present in `tests-passed`. I just tested it locally by setting the `max_image_width` setting to 340 and using a YouTube link in a post, and I cannot reproduce the issue.

So for the `stable` branch users, the solution is to wait until the next stable release.

---

<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: [August 13, 2026, 6:30pm UTC](https://meta.discourse.org/t/max-image-width-setting-cropping-youtube-previews/163605/12 "2026-08-13T18:30:47Z")

</div>


