Tweak prefix image size for DisplayAds on articles (#18260)

This commit is contained in:
Joshua Wehner 2022-08-04 21:41:25 +02:00 committed by GitHub
parent bfbb472b19
commit 2d271706c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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