Avi
Avi

Reputation: 51

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. And we have two servers containing same image to both locations. How I can refer two image tags under HTML page?

Two server locations : 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\">

If one server goes down it may lead to miss the client's logo under an email message body.

Could you please guide me on this part how we can refer to different servers for image path under the same tag.

Upvotes: 3

Views: 7878

Answers (3)

ademolu odujoko
ademolu odujoko

Reputation: 1

All tags must have a defined src attribute. This defines the image to be displayed. Typically, the src is a URL

Read more: https://html.com/tags/img/#ixzz60EqeFQgd

Upvotes: 0

img tag can only have one src attribute. 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

Upvotes: 0

PaulProgrammer
PaulProgrammer

Reputation: 17630

The <img> tag itself cannot support multiple source images. 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.

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.

How to display Base64 images in HTML?

Upvotes: 3

Related Questions