lostluke
lostluke

Reputation: 165

Use base url for image source html/js

Hey i get my html content via json. The image blocks look like:

src=\"/2017/03/test.jpg\" alt=\"test\" width=\"576\" height=\"800\" srcset=\"/2017/03/test.jpg 576w, /2017/03/test-112x155.jpg 112w, /2017/03/test-432x600.jpg 432w\" 

The src should look like mywebsite.com/img-src but it looks like localhost/img-src right now...

I tried to replace it via JavaScript but then it looks like: localhost/mywebsite.com/img-src

Does somebody have an idea

Edit: the image is hosted on ONE Website! And it should be shown on every device. Now its 404...

Upvotes: 2

Views: 9364

Answers (1)

mathmaniac88
mathmaniac88

Reputation: 640

It can be done by including a <base> tag in the <head> tag like this:

<base href="mywebsite.com/path">

For more information reference this webpage: https://www.w3schools.com/tags/tag_base.asp

Upvotes: 5

Related Questions