I have a column in my User
table called img
. The image is stored as a Base64 string. I tried using the following tag to show the image:
<img src="data:image/png;base64,${user.img}" alt="User image" />
While this works with letter opener / preview mode, it seems that Gmail doesn't support this.
I'm now trying to create the image as an inline image based on this post: https://stackoverflow.com/a/39710468/891359
What I don't understand is how to get the image correctly displayed. I tried the following combination:
In my mailer:
attachments.inline["user.png"] = {
:data => @user.img,
:mime_type => "image/png",
:encoding => "base64"
}
And in my template:
= image_tag attachments['user.png'].url
Unfortunately this shows up as a broken image icon in Gmail. Am I doing something wrong?