Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to swap a GIF in an HTML email with a different image for unsupported clients

I have a client that wants me to create a HTML email template for them. They want to include a banner image of an animated GIF, which is not supported in all email clients. The animation that they want would not have a readable first frame, and from my research, the email clients that do not render GIF formats will simply display the first frame of the GIF. I was wondering if there was a way to swap out the image used and serve a different image rather than a GIF for the email clients that do not support GIF formats. Thank you for your help!

like image 536
Liz Avatar asked Aug 19 '16 16:08

Liz


People also ask

How do you put a GIF in an email not as an attachment?

Click the “Insert” tab, and click “Pictures” on the ribbon. If the animated GIF is online, then click on “Online Pictures. Select the file, and then click “Insert.”· It would insert the file into your email message.

Do all email clients support GIFs?

You need to make sure that email clients will support your GIF files. The good news is that most email clients – like Gmail – support GIF files. Animated GIFs work in all webmail clients and most desktop and mobile clients. The only email client that can be stingy about sending GIFs in emails is Microsoft Outlook.


2 Answers

The easiest way is to design a GIF where the first frame is readable, but since that's not an option you can hack the clients that don't support GIFs.

Fortunately GIF support is pretty good, it's basically Windows Outlook 2007/2010/2013/2016 that don't support GIFs. So we target this range using Outlook Conditional CSS. Outlook 2007 - Version 12, so something like this should display what we want. (might need to fool around with exactly what tags get nested)

<!--[if gte mso 12]>
<td>
    <img src="fallback.jpg">
</td>
<![endif]-->

<!--[if !gte mso 12]><!-- -->
<td>
    <img src="animated.gif">
</td>
<!--<![endif]-->

Here is a good thread on Stack Overflow discussing various ways to target specific versions of desktop Outlook.

like image 190
Ted Goas Avatar answered Sep 25 '22 06:09

Ted Goas


Most email clients don't support scripting so this would be hard. But you could always use a second gif that does have a visible first frame that's a picture of whatever you want and then have the rest of the gif be transparent. Once you have this, you could overlay both gifs on top of each other. This way if the client supports animated gifs, your gif on top would become transparent and if it is not supported, you would see what ever the first frame is.

like image 25
IronWilliamCash Avatar answered Sep 22 '22 06:09

IronWilliamCash