Class: ActionMailer::InlinePreviewInterceptor
- Includes:
- Base64
- Defined in:
- actionmailer/lib/action_mailer/inline_preview_interceptor.rb
Overview
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 an HTML email in a web browser.
This interceptor is enabled by default. To disable it, delete it from the ActionMailer::Base.preview_interceptors
array:
ActionMailer::Base.preview_interceptors.delete(ActionMailer::InlinePreviewInterceptor)
Constant Summary collapse
- PATTERN =
/src=(?:"cid:[^"]+"|'cid:[^']+')/i
Class Method Summary collapse
-
.previewing_email(message) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#initialize(message) ⇒ InlinePreviewInterceptor
constructor
:nodoc:.
-
#transform! ⇒ Object
:nodoc:.
Constructor Details
#initialize(message) ⇒ InlinePreviewInterceptor
:nodoc:
24 25 26 |
# File 'actionmailer/lib/action_mailer/inline_preview_interceptor.rb', line 24 def initialize() #:nodoc: @message = end |
Class Method Details
.previewing_email(message) ⇒ Object
:nodoc:
20 21 22 |
# File 'actionmailer/lib/action_mailer/inline_preview_interceptor.rb', line 20 def self.previewing_email() #:nodoc: new().transform! end |
Instance Method Details
#transform! ⇒ Object
:nodoc:
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'actionmailer/lib/action_mailer/inline_preview_interceptor.rb', line 28 def transform! #:nodoc: return if html_part.blank? html_part.body = html_part.decoded.gsub(PATTERN) do |match| if part = find_part(match[9..-2]) %[src="#{data_url(part)}"] else match end end end |