class ActionMailer::InlinePreviewInterceptor
Implements a mailer preview interceptor that converts image tag src attributes that use inline cid: style urls to data: style urls so that they are visible when previewing a HTML email in a web browser.
This interceptor is not enabled by default, to use it just register it like any other mailer preview interceptor:
ActionMailer::Base.register_preview_interceptor(ActionMailer::InlinePreviewInterceptor)
Constants
- PATTERN
Private Instance Methods
data_url(part)
click to toggle source
# File lib/action_mailer/inline_preview_interceptor.rb, line 53 def data_url(part) "data:#{part.mime_type};base64,#{strict_encode64(part.body.raw_source)}" end
find_part(cid)
click to toggle source
# File lib/action_mailer/inline_preview_interceptor.rb, line 57 def find_part(cid) message.all_parts.find{ |p| p.attachment? && p.cid == cid } end
html_part()
click to toggle source
# File lib/action_mailer/inline_preview_interceptor.rb, line 45 def html_part @html_part ||= message.html_part end
html_source()
click to toggle source
# File lib/action_mailer/inline_preview_interceptor.rb, line 49 def html_source html_part.body.raw_source end
message()
click to toggle source
# File lib/action_mailer/inline_preview_interceptor.rb, line 41 def message @message end