# 帖子中的图片过宽，当“最大图片宽度”已设置时

**URL:** https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372
**Category:** Support
**Created:** [2019 年8 月 21 日 08:10 UTC](https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372 "2019-08-21T08:10:35Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### 作者： ![tohaitrieu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tohaitrieu/32/151338_2.png) [@tohaitrieu](https://meta.discourse.org/u/tohaitrieu)
#### 发布日期： [2019 年8 月 21 日 08:10 UTC](https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372/1 "2019-08-21T08:10:36Z")

</div>

今天，我发布了一篇新文章，预览部分的图片出现了边框溢出。

 ![34%20PM](https://global.discourse-cdn.com/meta/original/3X/2/e/2ed77f2bea2f842dc2ab8c76a000d59cee292976.png)

查看已发布的文章时，图片部分溢出并被隐藏。

 ![03%20PM](https://global.discourse-cdn.com/meta/original/3X/7/8/7875a025a0c2e178be6d951bf65970f24674953f.jpeg)

之前的文章没有遇到这种情况。这是一个 bug 吗？该如何修复？

链接：[https://babyforex.net/t/xu-huong-thi-truong-forex-21-08-2019-gold-xau-usd-gbp-usd-aud-usd/169](https://babyforex.net/t/xu-huong-thi-truong-forex-21-08-2019-gold-xau-usd-gbp-usd-aud-usd/169)

---

<div class="post-metadata">

### 作者： ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### 发布日期： [2019 年8 月 21 日 10:28 UTC](https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372/2 "2019-08-21T10:28:39Z")

</div>

让我看看，这是一张 1700 × 480 的图片：

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

看起来没问题。您是否在自己的网站上覆盖了 CSS，导致出现干扰？我无法复现宽图片出现的任何问题。

我也点击浏览了您的网站，在该主题下也没有发现任何问题。所有图片看起来都很正常，没有被人为裁剪。

请注意，嵌套引用（或仅使用引用）会限制帖子的宽度，因此在这些情况下您可能会观察到一些异常现象。

> > > > > 就像这样，假设这是一张图片

---

<div class="post-metadata">

### 作者： ![tohaitrieu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tohaitrieu/32/151338_2.png) [@tohaitrieu](https://meta.discourse.org/u/tohaitrieu)
#### 发布日期： [2019 年8 月 21 日 10:50 UTC](https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372/3 "2019-08-21T10:50:54Z")

</div>

我没发现任何问题。我必须在后台重写 CSS 来修复这个问题。

---

<div class="post-metadata">

### 作者： ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### 发布日期： [2019 年8 月 21 日 11:33 UTC](https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372/4 "2019-08-21T11:33:18Z")

</div>

我可以轻松复现，所以不确定您在说什么。请参见上方带有宽图的帖子。

---

<div class="post-metadata">

### 作者： ![tohaitrieu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tohaitrieu/32/151338_2.png) [@tohaitrieu](https://meta.discourse.org/u/tohaitrieu)
#### 发布日期： [2019 年8 月 21 日 12:17 UTC](https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372/5 "2019-08-21T12:17:09Z")

</div>

我录制了一段包含详细信息的视频：[https://www.youtube.com/watch?v=3uRjtTzXj7o](https://www.youtube.com/watch?v=3uRjtTzXj7o)

---

<div class="post-metadata">

### 作者： ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### 发布日期： [2019 年8 月 21 日 14:21 UTC](https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372/6 "2019-08-21T14:21:44Z")

</div>

该视频没有帮助，请尝试在 Meta 上重现此问题。在您的下一条回复中添加一张宽幅图片。

---

<div class="post-metadata">

### 作者： ![tohaitrieu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tohaitrieu/32/151338_2.png) [@tohaitrieu](https://meta.discourse.org/u/tohaitrieu)
#### 发布日期： [2019 年8 月 21 日 14:52 UTC](https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372/7 "2019-08-21T14:52:28Z")

</div>

这是我宽度为 1500 像素的图片。

 ![aud-usd-20190821](https://global.discourse-cdn.com/meta/original/3X/1/7/17814a61830a0c8e33360a0f1a2615bde1a81209.jpeg)

我检查后发现，这个 bug 仅出现在我引用另一篇文章的长内容时。

我认为这个 bug 源于引用 BB 代码。

其他所有文章都正常。

---

<div class="post-metadata">

### 作者： ![tohaitrieu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tohaitrieu/32/151338_2.png) [@tohaitrieu](https://meta.discourse.org/u/tohaitrieu)
#### 发布日期： [2019 年8 月 21 日 14:53 UTC](https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372/8 "2019-08-21T14:53:24Z")

</div>

查看

 ![xau-usd-20190821-h4-vai-dau-vai](https://global.discourse-cdn.com/meta/original/3X/5/e/5ea9b4ed93c404340075c9a22836a79db9f732d7.jpeg)

---

<div class="post-metadata">

### 作者： ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### 发布日期： [2019 年8 月 21 日 21:57 UTC](https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372/11 "2019-08-21T21:57:31Z")

</div>

我看上面的图片没什么问题？

---

<div class="post-metadata">

### 作者： ![tohaitrieu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tohaitrieu/32/151338_2.png) [@tohaitrieu](https://meta.discourse.org/u/tohaitrieu)
#### 发布日期： [2019 年8 月 22 日 16:50 UTC](https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372/12 "2019-08-22T16:50:31Z")

</div>

这意味着我的论坛存在问题。但我没有发现任何问题。我尝试移除了所有插件和主题组件，但无法修复此错误。

现在我必须在自定义 CSS 中添加以下代码来解决问题：

```
.d-editor-preview .image-wrapper img, .lightbox-wrapper img, .cooked img.d-lazyload {
    width: 100%;
    height: auto;
}

```

---

<div class="post-metadata">

### 作者： ![tohaitrieu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tohaitrieu/32/151338_2.png) [@tohaitrieu](https://meta.discourse.org/u/tohaitrieu)
#### 发布日期： [2019 年8 月 22 日 17:04 UTC](https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372/13 "2019-08-22T17:04:57Z")

</div>

我尝试将我的网站与 Discourse 的 CSS 进行了比较。

在我的网站上：

```
#reply-control .d-editor-preview img:not(.thumbnail), .cooked img:not(.thumbnail) {
    max-width: 1200px;
    max-height: 628px;
}

```

HTML：

`<img src="https://babyforex.net/uploads/default/original/1X/10670fd0bf4b34154ae4447feff1fc93f5eaed7e.jpeg" alt="h%C3%ACnh%20%E1%BA%A3nh" data-base62-sha1="2l6rNxc3PYiacNMqRTIM4GcaAjA" width="1200" height="526" class="d-lazyload">`

在 Discourse 上：

```
#reply-control .d-editor-preview img:not(.thumbnail), .cooked img:not(.thumbnail) {
    max-width: 690px;
    max-height: 500px;

```

HTML：

`<img src="https://global.discourse-cdn.com/meta/optimized/3X/e/9/e98710650be7c014168330f7c60d7081340c89cb_2_690x194.jpeg" alt="image" data-base62-sha1="xjSCGCdDwgRqb1OJkiAZNgbEQEr" width="690" height="194" class="d-lazyload" srcset="https://global.discourse-cdn.com/meta/optimized/3X/e/9/e98710650be7c014168330f7c60d7081340c89cb_2_690x194.jpeg, https://global.discourse-cdn.com/meta/optimized/3X/e/9/e98710650be7c014168330f7c60d7081340c89cb_2_1035x291.jpeg 1.5x, https://global.discourse-cdn.com/meta/optimized/3X/e/9/e98710650be7c014168330f7c60d7081340c89cb_2_1380x388.jpeg 2x">`

Discourse 始终为 690px。

但我的网站是 1200px，导致图片被隐藏了。

---

<div class="post-metadata">

### 作者： ![tohaitrieu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tohaitrieu/32/151338_2.png) [@tohaitrieu](https://meta.discourse.org/u/tohaitrieu)
#### 发布日期： [2019 年8 月 22 日 17:06 UTC](https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372/14 "2019-08-22T17:06:57Z")

</div>

这是我的错误，而不是 bug。我已经修复了。

将值更改为默认值。

 ![46%20AM](https://global.discourse-cdn.com/meta/original/3X/f/c/fc3d95efa69fd447a202c49cf9fef6e1fe38205f.png)

谢谢！

---

<div class="post-metadata">

### 作者： ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### 发布日期： [2019 年9 月 21 日 17:07 UTC](https://meta.discourse.org/t/images-in-posts-too-wide-when-max-image-width-is-set/126372/15 "2019-09-21T17:07:08Z")

</div>

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