diff --git a/lib/onebox/engine/allowlisted_generic_onebox.rb b/lib/onebox/engine/allowlisted_generic_onebox.rb index 3618c6028cc..8120c4ce877 100644 --- a/lib/onebox/engine/allowlisted_generic_onebox.rb +++ b/lib/onebox/engine/allowlisted_generic_onebox.rb @@ -257,6 +257,11 @@ module Onebox end def article_html + if data[:image] + data[:thumbnail_width] ||= data[:image_width] || data[:width] + data[:thumbnail_height] ||= data[:image_height] || data[:height] + end + layout.to_html end diff --git a/lib/onebox/templates/allowlistedgeneric.mustache b/lib/onebox/templates/allowlistedgeneric.mustache index b988e33c168..12343efb6ad 100644 --- a/lib/onebox/templates/allowlistedgeneric.mustache +++ b/lib/onebox/templates/allowlistedgeneric.mustache @@ -1,4 +1,4 @@ -{{#image}}{{/image}} +{{#image}}{{/image}}

{{title}}

diff --git a/plugins/chat/assets/stylesheets/common/chat-message-images.scss b/plugins/chat/assets/stylesheets/common/chat-message-images.scss index 09797aa28a5..9a846f43b41 100644 --- a/plugins/chat/assets/stylesheets/common/chat-message-images.scss +++ b/plugins/chat/assets/stylesheets/common/chat-message-images.scss @@ -21,7 +21,6 @@ $max_image_height: 150px; container-type: inline-size; .thumbnail { - max-width: 40% !important; &.onebox-avatar { max-height: 100px; width: 20%; diff --git a/spec/fixtures/onebox/assemblyai.response b/spec/fixtures/onebox/assemblyai.response new file mode 100644 index 00000000000..a56c9bf5c11 --- /dev/null +++ b/spec/fixtures/onebox/assemblyai.response @@ -0,0 +1,85 @@ + + + + + How RLHF Works (And How Things May Go Wrong) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb b/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb index e7ff04589a8..1c4679583fc 100644 --- a/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb +++ b/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb @@ -253,6 +253,25 @@ RSpec.describe Onebox::Engine::AllowlistedGenericOnebox do end describe "article html hosts" do + context "when returning an article_html with a thumbnail" do + before do + stub_request( + :get, + "https://www.assemblyai.com/blog/how-rlhf-preference-model-tuning-works-and-how-things-may-go-wrong/", + ).to_return(status: 200, body: onebox_response("assemblyai")) + end + + it "shows article thumbnail with correct size" do + onebox = + described_class.new( + "https://www.assemblyai.com/blog/how-rlhf-preference-model-tuning-works-and-how-things-may-go-wrong/", + ) + + expect(onebox.to_html).to include("width=\"1600\"") + expect(onebox.to_html).to include("height=\"900\"") + end + end + context "when returning article_html for hosts in article_html_hosts" do before do stub_request(:get, "https://www.imdb.com/title/tt0108002/").to_return(