简体   繁体   English

如何在 html email 中显示来自 Google Drive 的图片?

[英]How to display an Image from Google Drive in an html email?

I'm making a html leter right now, and the image I'm trying to display doesn't appear when I'm receiving it.我现在正在写一封 html 信件,但当我收到它时,我试图显示的图像并没有出现。 Here's the code:这是代码:

<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>demo</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>

<body style="margin: 0; padding: 0;">
    <table cellspacing="0" cellpadding="0" border="0" width="100%">
        <tr>
            <td>
                <table cellspacing="0" cellpadding="0" border="0" width="600px" align="center">
                    <tr>
                        <td>
                            <img src="https://drive.google.com/uc?export=view&id=1QJk7MIu-1hriNSyf1k71YyGwtQBqjy02" alt="Demo_image" srcset="">
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>

So, when I was viewing this page in a browser it looked fine (if it's okay to say so about html mailing), it also looked fine when I was sending it via Outlook, but the letter I received in gmail simply didn't have this image and was empty.所以,当我在浏览器中查看此页面时它看起来很好(如果可以这样说关于 html 邮件),当我通过 Outlook 发送它时它看起来也很好,但是我在 gmail 中收到的信根本没有这个图像是空的。

Google Drive is not built for hosting images publicly, AFAIK. Google 云端硬盘不是为公开托管图像而构建的,AFAIK。 You may need to use an image host specifically designed for it.您可能需要使用专门为其设计的图像主机。

However, you could try the following:但是,您可以尝试以下操作:

<img src="https://drive.google.com/uc?export=view&id=1QJk7MIu-1hriNSyf1k71YyGwtQBqjy02" alt="Demo_image" width="600">

I've removed the blank srcset, which might be interfering.我已经删除了空白的 srcset,这可能会造成干扰。 I've also added a width, which is normally added to the img tag.我还添加了一个宽度,通常添加到 img 标签中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM