email - 为什么我的图像在首次加载时未显示在旧电子邮件客户端上?
问题描述
我有一个在表格中设计的 HTML 电子邮件,以支持旧的电子邮件客户端。我正在使用sendgrid,因此图像值使用{{#each}}
这在大多数较新的客户端和浏览器上都可以正常工作,但在 2016 年之前的 Mac Mail 和 Outlook 上,主图像不会在您第一次查看电子邮件时显示。如果您在收件箱中查看另一封电子邮件并返回该邮件,它会神奇地出现。此外,一旦它被缓存,它就会每次都出现。
这就是我显示图像的方式。
<td class="img-container">
<a href="linkToSomewhere.html" style="text-decoration: none;">
{{#if this.hasPhoto}}
<img class="hero-img" alt="{{this.altText}}" src="https://somePlatform.xyz{{this.photoUrl}}.jpg" width="560" height="380" style="display: block; width: 560px; height: 100%;" />
{{/if}}
</a>
</td>
解决方案
我在这里添加这个是因为我找不到通过搜索解决这个问题的任何方法。我希望这可以帮助你。要解决这个奇怪的错误,您需要在 HTML 中为 img 保留空间。您可以在td
<td class="img-container" style="width: 100%; height: 380px;">
<a href="linkToSomewhere.html" style="text-decoration: none;">
{{#if this.hasPhoto}}
<img class="hero-img" alt="{{this.altText}}" src="https://somePlatform.xyz{{this.photoUrl}}.jpg" width="560" height="380" style="display: block; width: 560px; height: 100%;" />
{{/if}}
</a>
</td>
推荐阅读
- mongodb - 从 mongodb 数据中按日期获取每个唯一列字段的计数
- javascript - 我的 Javascript 中使用单选按钮运行的堆叠进度条出现问题
- laravel - 我部署到 aws 的 Laravel 应用程序无法正常工作
- r - 没有反映外部反应环境的变化?
- laravel - 如何防止多次保存相同的记录
- linux - 如果使用 shell 脚本在 catalina.out 文件中发生任何异常,我该如何重新启动 tomcat 服务器?
- python - 基于连续列值拆分数据帧,数据帧中不存在
- eclipse - 添加服务器时eclipse抛出swt错误
- c# - 使客户电子邮件字段独一无二
- .net-core - Blazor 服务器中的客户端何时/如何超时连接?