Onebox images with bad aspect when oEmbed specifies dimentions for rich HTML embeds

The dimensions are coming from oembed:

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

Which has:

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 --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.

1 Like