Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gmail removes background-size in my newsletter

I have an email newsletter, that contains product pictures of the products, which are promoted via newsletter. I use full size pictures and resize them with:

<table cellspacing="0" cellpadding="0" border="0" style="width: 201px; height: 240px; background-image: url({{ item1.picture }}); background-repeat: no-repeat; background-size: 100% auto;">

Gmail strips the

background-size: 100% auto;

tag and the pictures are shown in their full size. Is there any way how to fix this? I don't want to resize each picture on the server side.

like image 224
nu.frix Avatar asked Dec 05 '13 13:12

nu.frix


People also ask

Does Gmail support background image?

Since Gmail has started loading images by defult they are now supporting background images.

How do I display a background image in an email template?

Click Email templates. Click Create Template. Click the Code your own tab, and select Paste in code. In the Code Editor, insert the following code just after the opening <body> tag to add the placeholder background image and color.

Can you have a background image in an email?

You can add background images—with no coding required! To try it for yourself, sign up now for free. If you have an existing HTML email template, Campaign Monitor's “Bulletproof Background Images” has the code snippets you need to create email body background images.


1 Answers

I worked around this by using the background css shorthand method. Define the image, repeat, and size all in one line like so:

background: url({{ item1.picture }}) no-repeat top / 100% auto;

Notice that the size attribute should be defined after the position attribute ('top') and delimited with '/'.

like image 180
Justin McDonald Avatar answered Oct 03 '22 15:10

Justin McDonald