mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:30:26 -06:00
FIX: add 'max-width' to images with auto width/height in emails
This commit is contained in:
parent
d56e91f44f
commit
e2121c2c2c
@ -31,7 +31,6 @@ module Email
|
||||
|
||||
# images
|
||||
@fragment.css('img').each do |img|
|
||||
|
||||
next if img['class'] == 'site-logo'
|
||||
|
||||
if img['class'] == "emoji" || img['src'] =~ /plugins\/emoji/
|
||||
@ -56,9 +55,16 @@ module Email
|
||||
end
|
||||
end
|
||||
|
||||
# add max-width to big images
|
||||
big_images = @fragment.css('img[width="auto"][height="auto"]') -
|
||||
@fragment.css('aside.onebox img') -
|
||||
@fragment.css('img.site-logo, img.emoji')
|
||||
big_images.each do |img|
|
||||
add_styles(img, 'max-width: 100%;') if img['style'] !~ /max-width/
|
||||
end
|
||||
|
||||
# attachments
|
||||
@fragment.css('a.attachment').each do |a|
|
||||
|
||||
# ensure all urls are absolute
|
||||
if a['href'] =~ /^\/[^\/]/
|
||||
a['href'] = "#{Discourse.base_url}#{a['href']}"
|
||||
|
Loading…
Reference in New Issue
Block a user