mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 04:03:57 -06:00
add support for inline images in emails in
This commit is contained in:
parent
478062ba71
commit
dd28a3c63a
@ -122,15 +122,12 @@ module Email
|
||||
|
||||
def select_body(message)
|
||||
html = nil
|
||||
# If the message is multipart, return that part (favor html)
|
||||
if message.multipart?
|
||||
html = fix_charset message.html_part
|
||||
text = fix_charset message.text_part
|
||||
|
||||
# prefer plain text
|
||||
if text
|
||||
return text
|
||||
end
|
||||
if message.multipart?
|
||||
text = fix_charset message.text_part
|
||||
# prefer text over html
|
||||
return text if text
|
||||
html = fix_charset message.html_part
|
||||
elsif message.content_type =~ /text\/html/
|
||||
html = fix_charset message
|
||||
end
|
||||
@ -247,7 +244,13 @@ module Email
|
||||
# create the upload for the user
|
||||
upload = Upload.create_for(user.id, tmp, attachment.filename, tmp.size)
|
||||
if upload && upload.errors.empty?
|
||||
# TODO: should use the same code as the client to insert attachments
|
||||
# try to inline images
|
||||
if attachment.content_type.start_with?("image/")
|
||||
if raw =~ /\[image: Inline image \d+\]/
|
||||
raw.sub!(/\[image: Inline image \d+\]/, attachment_markdown(upload))
|
||||
next
|
||||
end
|
||||
end
|
||||
raw << "\n#{attachment_markdown(upload)}\n"
|
||||
end
|
||||
ensure
|
||||
|
Loading…
Reference in New Issue
Block a user