在台式机和移动设备上切换图像以发送电子邮件| Mailjet

问题描述 投票:0回答:1

我们正在切换为使用Mailjet API发送电子邮件。我们现在面临的一个问题是:我们为html主体使用apache速度模板,在html的src标记中提供图像url。但是出于明显的原因(图像尺寸等),我们在台式机,移动设备/ ipad上使用的图像有所不同]

我们如何确定何时在客户端设备上呈现电子邮件,将显示哪个横幅。 mailjet是否具有任何切换图像功能?

谢谢。

email html-email velocity mailjet velocity-template-language
1个回答
0
投票

如果您需要交换图像,而不仅仅是缩小图像(style="width:100%;height:auto;"),则响应方式如下:

将此添加到<head>部分:

<style>
    @media screen and (max-width:620px) {
        .image_mobile {
            display:block!important; max-height: none !important; max-width:none !important; line-height: 1.5 !important;width:100%!important; height:auto!important;
        }
        .hide {
            display:none!important; width:0px!important; height: 0px!important; overflow:hidden!important; line-height: 0px!important; font-size:0px!important;
        }
    }
</style>

并将其放在您的内容中:

<img border="0" width="xxx" src="xxx" alt="xxx" style="display:block; outline:none; text-decoration:none; -ms-interpolation-mode: bicubic;width:100%;height:auto;" class="hide">
<!--[if mso]><!-->
<div style="display:none; font-size:0; line-height:0;  max-height: 0; max-width: 0; width:0;" class="image_mobile">
    <img border="0" width="xxx" src="xxx" alt="xxx" style="display:none; font-size:0; line-height:0;max-height: 0; max-width: 0; width:0; -ms-interpolation-mode: bicubic;" class="image_mobile">
</div>
<!--<![endif]-->

默认情况下,将显示第一张图片(桌面;网络邮件;不支持@media的用户)。但是大多数移动应用程序将支持@media,因此将隐藏第一个图像,然后显示第二个图像。

(因此,它不是Mailjet的功能,而是您的代码)

© www.soinside.com 2019 - 2024. All rights reserved.