Spilot
Spilot

Reputation: 1525

why is the path for my img tag src attribute failing?

I've tried every possible relative path combination I can think of and I'm still getting a broken img icon on my page when I try to load it. The only thing that works is when I test an absolute path from a sample pic on the web.

The image i'm trying to load is in the exact same directory as the html page I want to load it to.

My file structure is as follows

                              src -> 
                                  pages -> 
                                         home-> 
                                                - home.html 

                                                - vectorstock_1623.jpg

Home.html

<img src="vectorstock_1623.jpg"/>

Upvotes: 3

Views: 60

Answers (1)

sebaferreras
sebaferreras

Reputation: 44659

You need to put the image in the src/assets folder. You can create an img folder inside the assets folder so your image will be placed in:

src/assets/img

and then in the view use this path:

<img src="assets/img/vectorstock_1623.jpg">

Upvotes: 2

Related Questions