From 2d271706c3f372fb1c84233f5cdffa812f52983e Mon Sep 17 00:00:00 2001 From: Joshua Wehner Date: Thu, 4 Aug 2022 21:41:25 +0200 Subject: [PATCH] Tweak prefix image size for DisplayAds on articles (#18260) --- app/models/display_ad.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/display_ad.rb b/app/models/display_ad.rb index b29d9b636..5b1463efe 100644 --- a/app/models/display_ad.rb +++ b/app/models/display_ad.rb @@ -7,6 +7,9 @@ class DisplayAd < ApplicationRecord "Sidebar Right", "Below the comment section"].freeze + POST_WIDTH = 775 + SIDEBAR_WIDTH = 350 + belongs_to :organization, optional: true has_many :display_ad_events, dependent: :destroy @@ -41,6 +44,11 @@ class DisplayAd < ApplicationRecord tags: MarkdownProcessor::AllowedTags::DISPLAY_AD, attributes: MarkdownProcessor::AllowedAttributes::DISPLAY_AD html = stripped_html.delete("\n") - self.processed_html = Html::Parser.new(html).prefix_all_images(350, synchronous_detail_detection: true).html + self.processed_html = Html::Parser.new(html) + .prefix_all_images(prefix_width, synchronous_detail_detection: true).html + end + + def prefix_width + placement_area.to_s == "post_comments" ? POST_WIDTH : SIDEBAR_WIDTH end end