Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular : Failed to load images: 404 (Not Found)

i download this free theme in order to use it in my angular project in WebStorm but i get this error :
Failed to load resource: the server responded with a status of 404 (Not Found) and no image is loaded even if the path is right. can anyone help me with that?

here is a snippet of the code:

 <a class="navbar-brand brand-logo" href="index.html"><img src="images/logo.svg" alt="logo"/></a>
      <a class="navbar-brand brand-logo-mini" href="index.html"><img src="images/logo-mini.svg" alt="logo"/></a>

What i get

Directory tree structure

PS: i did have problems with loading CSS and JavaScript files but i'v already solved them by adding type="text/html" in css links and type="application/json" in JavaScript links. do you think it can be a JSON problem?

like image 570
chimchim Avatar asked Oct 27 '25 08:10

chimchim


2 Answers

I solved this issue by placing images into assets folder of Angular. Previously I placed them into app folder and had 404 error too, but placing into assets solved my issue. So I use them like:

<img src="assets/images/intro_room.jpg" alt="Intro Gallery Room Sample Pictures">
like image 113
Konstantin Kozirev Avatar answered Oct 28 '25 22:10

Konstantin Kozirev


You have to add the route in angular.json in architect > build > options > assets:

"assets": ["src/favicon.ico", "src/assets", "src/images"]

After this you have to stop it and relaunch you app.

like image 22
Iván Gómez Avatar answered Oct 28 '25 21:10

Iván Gómez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!