inlined mailer template images

completes #81
This commit is contained in:
Mark Moser 2016-09-16 12:57:24 -05:00
parent a51a751524
commit 5ac9b530fe
2 changed files with 18 additions and 3 deletions

View File

@ -2,4 +2,19 @@
class ApplicationMailer < ActionMailer::Base class ApplicationMailer < ActionMailer::Base
default from: ENV['default_mail_from'] default from: ENV['default_mail_from']
layout 'mailer' layout 'mailer'
before_action :inline_layout_images
private
def inline_layout_images
# inline images requested in default mailer layout
attachments.inline['perficientdigital-logo.jpg'] = image_file('perficientdigital-logo.jpg')
attachments.inline['yellowslant-left.jpg'] = image_file('yellowslant-left.jpg')
attachments.inline['yellowslant-right.jpg'] = image_file('yellowslant-right.jpg')
end
def image_file image
File.read(Rails.root.to_s + "/app/assets/images/#{image}")
end
end end

View File

@ -26,7 +26,7 @@
&copy;2016 All Rights Reserved - Perficient Digital &copy;2016 All Rights Reserved - Perficient Digital
</td> </td>
<td class="email-logo"> <td class="email-logo">
<%= image_tag("perficientdigital-logo.jpg", alt:"Perficient Digital") %> <%= image_tag(attachments["perficientdigital-logo.jpg"].url, alt:"Perficient Digital") %>
</td> </td>
</tr> </tr>
</table> </table>
@ -37,13 +37,13 @@
<table> <table>
<tr> <tr>
<td style="width:6px;"> <td style="width:6px;">
<%= image_tag("yellowslant-left.jpg", alt:"Perficient Digital") %> <%= image_tag(attachments["yellowslant-left.jpg"].url, alt:"Perficient Digital") %>
</td> </td>
<td class="email-bg" style="font-size:1px;"> <td class="email-bg" style="font-size:1px;">
&nbsp; &nbsp;
</td> </td>
<td style="width:6px;"> <td style="width:6px;">
<%= image_tag("yellowslant-right.jpg", alt:"Perficient Digital") %> <%= image_tag(attachments["yellowslant-right.jpg"].url, alt:"Perficient Digital") %>
</td> </td>
</tr> </tr>
</table> </table>