2

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...

3
  • I'm unclear about what the problem is. May you edit your question to be clearer? Commented Mar 7, 2017 at 15:28
  • Either append the URL before it populates the source of your image, or use JS to find all the images and change their source to include it. Commented Mar 7, 2017 at 15:29
  • 1
    I would suggest do not touch src. If server returns response like this then it is meant to look like this. Instead, if you're working on localhost create virtual host, for example dev.mysite.com configure Apache to point it to subfolder, for example /var/www/html/mysite/img-src Commented Mar 7, 2017 at 15:32

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.