Blog


Repurpose your Images for Mobile Email

10.19.2011

Read More Design Emails for Mobile Devices

Get connected with Email on Acid for up-to-date news and information on the subject of email design, development, and testing!

Email Testing RSS Feed Email Test on Twitter Email Preview on Digg Email CSS on Linked In Email Simulator on Stumbled Upon

Email Testing RSS Feed Email Test on Twitter Email Preview on Digg Email CSS on Linked In Email Simulator on Stumbled Upon

By mklann
October 19, 2011
 

Repurpose your Images for Mobile Email

As open rates for mobile devices continue to skyrocket, we've seen an increased level of interest from people who are developing emails that render flawlessly on desktop and mobile email clients.

Replacing and/or re-using graphics is a great place to start for a few different reasons:

iPhone
The iPhone scales your email down by default so that the widest element in the email fits within its viewport. From there, the user must scale it back up (outward pinch) in order to read it.  After scaling up your email, they will be forced to scroll left and right to read each line. By resizing your widest graphic and/or HTML container, you can control the size of your text at first glance.

Android
The Android handles text readability much differently. In this device, your text (usually) wraps within the center viewport and the rest of the graphics and/or HTML containers can be scrolled from left to right. Therefore, important messages often get cut off to the right of the viewport window. Check out our Android demo to see what I mean.

Code Examples

Using media queries, you can control the way various page elements render in the iPhone and Android. Here are a few examples for handling images:

1.) Re-size and re-use the same image (better for overall file size):

<style type="text/css">
   @media only screen and (max-device-width:480px;) {
      body[yahoo] .header { width:300px}
    }
</style>

<body yahoo="fix">
    <img src="http://www.url.com/image.jpg" class="header" width="600" height="100" />
</body>

 

2.) Completely replace your image(s):

<style type="text/css">
    @media only screen and (max-device-width:480px;) {
        body[yahoo] .mobile_only {
           width:600px !important;
           overflow:visible !important;
           float: none !important;
           display: block !important;
           }
        body[yahoo] .desktop_header { display:none}
        }
</style>

<body yahoo="fix">
    <div class="mobile_only" style="width:0px; overflow:hidden;float:left;display:none">
       Image for mobile - width="300px":
      <img src="http://www.url.com/image1.jpg" width="300" height="100" />
    </div>
    <div class="desktop_header">
        Image for desktop  - width="600px":
        <img src="http://www.url.com/image2.jpg" width="600" height="100" />
    </div>
</body>


Important: We used overflow, width and float above because Gmail does not support the "display" property if the value is set to "none."  We left the display:none in there for all other clients.

We also incorporated this Yahoo fix in both examples.

 

Comments

Depending on how you've build your email, you may also need to set a height of 0 for the hidden content, otherwise it still renders and breaks your layout in gmail.
By Jacques on 10/20/2011

Actually upon further testing, the technique works fine for inline elements like images, but completely breaks for stuff like paragraph tags.

You also can't use the technique to selectively show or hide cells, unfortunately.
By Jacques on 10/20/2011

And it looks like hidden images show up in Outlook 2007.

Technique 2 doesn't appear to be a great choice, unless you're emailing people that don't use Outlook.
By Jacques on 10/20/2011

Jacques, thanks for your feedback! Option 2 is not for the faint of heart that's for sure!

In response to your comments:

1.) In my testing, I learned that Gmail converts the "height" property to "min-height" which has an adverse affect cross browser. That's why I used the "width" property only.

2.) Regarding the inline elements, I just tested the following:

<div class="mobile_only" style="width:0px; overflow:hidden;float:left;display:none">
Image for mobile - width="300px":
http://www.emailonacid.com/images/EOA_logo.gif
< p >paragraph< /p >
<div>div</div>
<table><tr><td>table 1</td></tr></table>
<table style="display:none"><tr><td>table 2</td></tr></table>
</div>
(was forced to add spaces in order to get p tags to show up in these comments)

The only thing that rendered in Outlook 2007 was table 1. So it looks like if you want to nest tables in this option, you must include an inline style with display:none and overwrite that in your media query as well. Not sure about nested elements within that table so this is one I would "handle with care."

3.) You are correct, adding an inline style of display:none to an image does not work in Outlook 07/10, the workaround is to place it in a hidden div as shown in my example for Option 2.

Since there are so many nuances when using this technique it's really important to test in all clients before sending the final email blast smile
By mklann on 10/20/2011

Thanks Michelle,

You're right, adding the div completely hides the image in Outlook 2007, though the hidden text will still cause issues in Gmail.

I need to make a few more tests for hidden tables and cells, but initial testing isn't proving great.

At best we'll be able to hide certain content for mobile and show optimized images.
By Jacques on 10/21/2011

Great article, thanks!

Its working great so far except for one issue, I cannot seem to make it work in Android 2.2 Gmail. It does work for Android 2.2 Native.

Any ideas?
By Jon on 11/09/2011

Jon,

Yeah unfortunately this fix only works for the native email clients on the Android and iPhone. Since desktop and mobile versions of Gmail do not support embedded styles, I don't know of any other way to detect the device via inline CSS.
By mklann on 11/09/2011

Share Your Comment

Name:
Email:
Location:
URL:

Comment:

Remember my personal information
Notify me of follow-up comments?

Please enter the word you see in the image below:



Share/Save/Bookmark

If you haven't signed up yet, give our FREE online Email Test a try. Just drop in your code and we will instantly simulate your email in the most popular email clients!

Get connected with Email on Acid for up-to-date news and information on the subject of email design, development, and testing!

Email Testing RSS Feed Email Test on Twitter Email Preview on Digg Email CSS on Linked In Email Simulator on Stumbled Upon

Follow us on Twitter Become a Friend on Facebook Subscribe to our Blog Digg Us! Recommend on StumbleUpon