多次使用 Base64 嵌入图像
我在 HTML 文档中有几个小图像,我想将其移植,例如在发送电子邮件时仍然有效。我使用以下内容,效果很好:
<img src="data:image/png;base64,..."/>
问题是,我想在文档中多次使用相同的图像,但不想重复整个 base64 数据字符串。我在电子邮件中看到数据被编码一次,但引用了很多次。这可以用 HTML 实现吗?
I have a couple small images in an HTML document that I want to make portable, e.g. still works when emailing. I use the following, which works great:
<img src="data:image/png;base64,..."/>
Problem is, I want to use the same image many times in the document, but don't want to repeat the entire base64 data string. I have seen in emails where the data is encoded a single time, but referenced many. Is this possible with HTML?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您可以使用 CSS,则可以将其作为类放置在那里。
然后只需将类添加到您想要的元素即可。
If you can use CSS, you could place it there instead, as a class.
Then just add the class to the elements you want.
配置您的网络服务器以 zgip (/deflate) 您的内容。 Deflate 应该检测重复的字符串,并压缩到与仅包含一次的大小相同的大小。这样您就不会浪费带宽。不适用于电子邮件或文件系统中的纯 html 文件。
Configure your webserver to zgip (/deflate) your content. Deflate should detect the repeating string and compress to about the same size as you would have if you only included it once. This way you won't waste bandwidth. Doesn't work for email, or for plain html-file in filesystem.