# התמונות ב-Onebox יש גורם אספקט שגוי

**URL:** https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098
**Category:** Bug
**Tags:** onebox
**Created:** [29 באוגוסט,‏ 2023,‏ 8:05pm UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098 "2023-08-29T20:05:00Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![jrivettcsa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jrivettcsa/32/151272_2.png) [@jrivettcsa](https://meta.discourse.org/u/jrivettcsa)
#### Post date: [29 באוגוסט,‏ 2023,‏ 8:05pm UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/1 "2023-08-29T20:05:00Z")

</div>

I’ve tried this with page links from a couple of different Wordpress sites, and the effect is the same:

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/c/5/9c56a144e7a2fa424ca158e61db31ff3ff6d0636.png)

Both sites definitely have valid OG tags. Image sources are square. We’re not specifying image dimensions in the OG tags.

The example above works fine in the Facebook sharing debugger and iFramely. Click the link below to see it on iFramely.

> **[Generate responsive embed codes - Iframely](https://iframely.com/try?url=https%3A%2F%2Fhookproductivity.com%2Fhelp%2Fintegration%2Fother-app-developers%2F)**
>
> Get responsive embed codes for your YouTube, Vimeo or over 1900 others

I reviewed all the onebox and image settings but I don’t see anything that seems relevant.

I went through the onebox troubleshooting and configuration guides here, but nothing helped.

I figure it has to be something in our Discourse settings, or in Discourse itself.

---

<div class="post-metadata">

### Author: ![jrivettcsa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jrivettcsa/32/151272_2.png) [@jrivettcsa](https://meta.discourse.org/u/jrivettcsa)
#### Post date: [29 באוגוסט,‏ 2023,‏ 8:08pm UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/2 "2023-08-29T20:08:32Z")

</div>

Let’s see what that link looks like on this Discourse instance:

> **[Contacting Developers of Other Apps and Information for Developers – Hookmark](https://hookproductivity.com/help/integration/other-app-developers/)**
>
> Hookmark uses AppleScript to integrate with apps, but not all apps are scriptable or sufficiently scriptable. Suppose you open a previously saved resource (document or object) in an app and then invoke Hookmark, but Hookmark is empty except for...

When I pasted that in, the onebox in the preview briefly showed the image with the correct aspect. A second or two later it got squashed.

So whatever is going on isn’t limited to our Discourse instance. I guess we might need to specify the image dimensions in the OG tags, but I didn’t think that was required.

---

<div class="post-metadata">

### Author: ![jrivettcsa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jrivettcsa/32/151272_2.png) [@jrivettcsa](https://meta.discourse.org/u/jrivettcsa)
#### Post date: [12 בספטמבר,‏ 2024,‏ 6:15pm UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/3 "2024-09-12T18:15:17Z")

</div>

So… any progress on this? It’s still happening. If there’s some kind of workaround, let me know. If we’re doing something incorrectly, let me know.

---

<div class="post-metadata">

### Author: ![jrivettcsa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jrivettcsa/32/151272_2.png) [@jrivettcsa](https://meta.discourse.org/u/jrivettcsa)
#### Post date: [6 ביולי,‏ 2025,‏ 12:59pm UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/4 "2025-07-06T12:59:58Z")

</div>

דוח מצב: זה עדיין קורה. כאשר אני מדביק קישור לנושא חדש, בתחילה התמונה המשויכת נראית בסדר בתצוגה המקדימה. אבל ברגע שאני לוחץ על Enter או על מקש הרווח, התמונה נמעכת. בדקתי שוב את שלבי פתרון הבעיות של onebox, ושוב סקרתי את כל ההגדרות שבוטלו, ללא הצלחה. זה מטורף.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [6 ביולי,‏ 2025,‏ 1:37pm UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/5 "2025-07-06T13:37:54Z")

</div>

That CSS could be considered suboptimal or might be some kind of compromise. I’m on the hoof but perhaps it’s currently enforcing 16:9. Not great for square logos 🙂

~~I wonder if height could be set to auto? (Although that might present challenges for portrait images)~~

---

<div class="post-metadata">

### Author: ![jrivettcsa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jrivettcsa/32/151272_2.png) [@jrivettcsa](https://meta.discourse.org/u/jrivettcsa)
#### Post date: [6 ביולי,‏ 2025,‏ 5:38pm UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/7 "2025-07-06T17:38:03Z")

</div>

לאיזה CSS אתה מתייחס? כלומר, ייתכן שאתה צודק, אבל אני מנסה לקבוע אם זו בעיה שאני יכול לתקן בהתקנה שלנו של Discourse, או אם זו בעיה במקורות של Discourse.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [6 ביולי,‏ 2025,‏ 5:42pm UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/8 "2025-07-06T17:42:29Z")

</div>

Back at desk:

![image](https://global.discourse-cdn.com/meta/original/4X/c/6/c/c6c124b8eb941e8c1919b56c5d553a7c509631db.png)

That’s presumably a coded style so you’d need to dig into the code to find out how it’s set.

When `600 / 600` your logo is square …

Here you go:

> <https://github.com/discourse/discourse/blob/27a7e26594bb2bffe2db4a7361787b322e936ad0/lib/cooked_processor_mixin.rb#L92>

---

<div class="post-metadata">

### Author: ![jrivettcsa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jrivettcsa/32/151272_2.png) [@jrivettcsa](https://meta.discourse.org/u/jrivettcsa)
#### Post date: [6 ביולי,‏ 2025,‏ 6:02pm UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/9 "2025-07-06T18:02:11Z")

</div>

מעניין. יש שם קוד שמניח הנחות לגבי תמונה אם היא ריבועית. אולי אנסה תמונה לא ריבועית.

---

<div class="post-metadata">

### Author: ![jrivettcsa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jrivettcsa/32/151272_2.png) [@jrivettcsa](https://meta.discourse.org/u/jrivettcsa)
#### Post date: [6 ביולי,‏ 2025,‏ 6:04pm UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/10 "2025-07-06T18:04:55Z")

</div>

תמונה לא מרובעת בשימוש כשכל השאר זהה: אין בעיות יחס. אמשיך להתנסות.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [6 ביולי,‏ 2025,‏ 6:09pm UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/11 "2025-07-06T18:09:33Z")

</div>

> [@jrivettcsa](#):
>
> looks fine in the preview

It would:

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

Uses the original dimensions and aspect.

This is stripped during the cooking process.

---

<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: [7 ביולי,‏ 2025,‏ 4:46am UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/13 "2025-07-07T04:46:09Z")

</div>

The dimensions are coming from oembed:

```plaintext
https://hookproductivity.com/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fhookproductivity.com%2Fhelp%2Fintegration%2Fother-app-developers%2F

```

Which has:

 ![This image displays a web page with embedded content related to contacting developers of other apps and integration information, as indicated by the HTML code and title. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/7/4/e/74e0cf27f5c30e65e5c1538df506d7a25566e685.png)

I think the bug here is that if the type is “rich”, and we are not grabbing the entire presentation from oembed `html` payload, we should skip adding dimensions, cause we are not interested in this data.

This fixes it:

```diff
diff --git a/lib/onebox/engine/standard_embed.rb b/lib/onebox/engine/standard_embed.rb
index e3175d6247..fc8c300d81 100644
--- a/lib/onebox/engine/standard_embed.rb
+++ b/lib/onebox/engine/standard_embed.rb
@@ -159,8 +159,9 @@ module Onebox
         @json_ld ||= Onebox::JsonLd.new(html_doc)
       end
 
- def set_from_normalizer_data(normalizer)
+ def set_from_normalizer_data(normalizer, skip_dimensions: false)
         normalizer.data.each do |k, _|
+ next if skip_dimensions && k.in?(%i[width height])
           v = normalizer.public_send(k)
           @raw[k] ||= v unless v.nil?
         end
@@ -179,7 +180,8 @@ module Onebox
 
       def set_oembed_data_on_raw
         oembed = get_oembed
- set_from_normalizer_data(oembed)
+ skip_dimensions = oembed.data[:type] == "rich"
+ set_from_normalizer_data(oembed, skip_dimensions:)
       end
 
       def set_json_ld_data_on_raw

```

However I am not sure what other side effects this would have, flagging the member-experience team who will have a look at this over the next month.

I am reluctant to simply add my patch cause there are lots of layers here and complexity, someone needs to ensure we are able to add the patch in a very safe and tested way.

* * *

This is pri-medium cause the impact of this bug is quite wide given wp-json surfaces this.

---

<div class="post-metadata">

### Author: ![jrivettcsa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jrivettcsa/32/151272_2.png) [@jrivettcsa](https://meta.discourse.org/u/jrivettcsa)
#### Post date: [7 ביולי,‏ 2025,‏ 11:52am UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/14 "2025-07-07T11:52:52Z")

</div>

Nice! That oembed data does seem to be the smoking gun. Interestingly, the Wordpress (software) documentation only talks about oembed in terms of Wordpress sites embedding content from _other_ sites, not the reverse. However, the [wordpress.com](http://wordpress.com) (service) documentation says “Every post, page, attachment, and VideoPress video hosted on [WordPress.com](https://wordpress.com/) supports the [oEmbed format](https://oembed.com/) through our public oEmbed API.” So it’s probably safe to assume that the Wordpress software does this by default.

I reviewed all the Wordpress settings, and was unable to find anything related to oembed, so it looks like any assumptions made by Wordpress are built into the code.

The Wordpress oembed API also explains why there’s no reference to the 600/338 dimensions anywhere in the page source, which I previously found baffling.

I agree that any possible fix for this in Discourse may have many (possibly unwanted) knock-on effects, and needs to be tested before being released.

Also, I’m not even sure that this is a Discourse problem. The bogus ‘338’ dimension is coming from Wordpress. It seems to me that there should be a way in Wordpress to override any oembed-related defaults like this. I plan to look for a Wordpress plugin that allows more control over oembed.

Thanks!

---

<div class="post-metadata">

### Author: ![jrivettcsa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jrivettcsa/32/151272_2.png) [@jrivettcsa](https://meta.discourse.org/u/jrivettcsa)
#### Post date: [8 ביולי,‏ 2025,‏ 10:29am UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/15 "2025-07-08T10:29:38Z")

</div>

מצד שני, מאחר שהקישורים האלה נראים בסדר ב-iFramely ובמקומות אחרים, אולי זה באמת משהו שצריך לשנות ב-Discourse.

---

<div class="post-metadata">

### Author: ![davidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidb/32/554671_2.png) [@davidb](https://meta.discourse.org/u/davidb)
#### Post date: [21 בינואר,‏ 2026,‏ 10:16am UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/22 "2026-01-21T10:16:31Z")

</div>

This one was missed previously but it should now be fixed with this change:

[https://github.com/discourse/discourse/commit/fb2a2c02f106f29ee7837bf7c5bd94361ee9c330](https://github.com/discourse/discourse/commit/fb2a2c02f106f29ee7837bf7c5bd94361ee9c330)

---

<div class="post-metadata">

### Author: ![davidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidb/32/554671_2.png) [@davidb](https://meta.discourse.org/u/davidb)
#### Post date: [26 בינואר,‏ 2026,‏ 10:17am UTC](https://meta.discourse.org/t/onebox-images-with-bad-aspect-when-oembed-specifies-dimentions-for-rich-html-embeds/277098/23 "2026-01-26T10:17:12Z")

</div>

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