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