0

In my react-app I want to load images with an absolute path. I get the path as a string from an api response. So its not possible to put image folder in the src oder public folder. I read several stackoverflow-question but nothing helped so far. The path I'm getting looks like this

"\\SRMS508\Dokumente\1\Artikel\Art.Nr 100085\100085_CIMG7224.JPG"

And neither this:

<img src="\\SRMS508\\Dokumente\1\Artikel\Art.Nr 100085\100085_CIMG7224.JPG"/>

not this:

<img src={require("\\SRMS508\\Dokumente\1\Artikel\Art.Nr 100085\100085_CIMG7224.JPG").default} />

is working.

And I would be very happy if anyone could help me with this.

1
  • 1
    you need to set path relative from where you are rendering Commented Feb 3, 2022 at 10:22

1 Answer 1

2

If you keep your images in the public folder where we keep all static assets like images then we can access them as:

Folder: public/images/

<img src="/images/logo.png" />
Sign up to request clarification or add additional context in comments.

2 Comments

Thats the problem. I can't keep the images in the public folder.
then If you use svg you can import as component where relate path can work but it won't work for jpg

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.