简体   繁体   English

我们可以在 html img src 标签中添加多个图像源吗?

[英]Can we add multiple image sources to html img src tag?

I have a scenario where we send an email to the user end includes clients logo image.我有一个场景,我们向用户端发送 email 包括客户徽标图像。 And we have two servers containing same image to both locations.我们有两台服务器,两个位置都包含相同的图像。 How I can refer two image tags under HTML page?如何在 HTML 页面下引用两个图像标签?

Two server locations: https://server1/dir/image https://server1/dir/image两个服务器位置: https://server1/dir/image https://server1/dir/image

Below is current tag we are using... https://server1/dir/image" width=\"148\" height=\"auto\" alt=\"logo\">以下是我们正在使用的当前标签... https://server1/dir/image" width=\"148\" height=\"auto\" alt=\"logo\">

If one server goes down it may lead to miss the client's logo under an email message body.如果一台服务器出现故障,可能会导致错过 email 消息正文下的客户端徽标。

Could you please guide me on this part how we can refer to different servers for image path under the same tag.您能否在这部分指导我如何在同一标签下引用不同服务器的图像路径。

The <img> tag itself cannot support multiple source images. <img>标签本身不能支持多个源图像。 The typical solution is to use a load balancer to direct the user to whatever server is actually up.典型的解决方案是使用负载平衡器将用户引导到实际启动的任何服务器。 The load balancer can be something fancy like a hardware load balancer, something easy like multiple DNS A records, or a CDN service that manages content distribution.负载均衡器可以像硬件负载均衡器一样花哨,也可以像多个 DNS A 记录或管理内容分发的 CDN 服务一样简单。

If this is specific to email, you can use a data: source, that embeds the image directly in the message, so it doesn't rely on a network service at all.如果这是特定于 email,您可以使用data:源,将图像直接嵌入消息中,因此它根本不依赖网络服务。

How to display Base64 images in HTML? 如何在 HTML 中显示 Base64 图像?

img tag can only have one src attribute. img 标签只能有一个 src 属性。 I'd suggest you use a CDN eg cloudinary to host the image and reference the link to the image in the email you are sending我建议您使用 CDN 例如 cloudinary 来托管图像并引用指向您发送的 email 中的图像的链接

All tags must have a defined src attribute.所有标签都必须具有定义的 src 属性。 This defines the image to be displayed.这定义了要显示的图像。 Typically, the src is a URL通常,src 是 URL

Read more: https://html.com/tags/img/#ixzz60EqeFQgd阅读更多: https://html.com/tags/img/#ixzz60EqeFQgd

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

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