Search code examples
ionic-frameworkionic4

Image not loading on ionic serve due to path problem in Ionic 4


When I am doing ionic serve, it loads home.html. I am calling image there. For some reason the images are kept at xampp/htdocs/files/hydrocarbon_files/image001.gif

In normal HTML it loads image perfectly fine but in Ionic project, image path is shown as

http://localhost:8100/files/hydrocarbon_files/image001.gif

It does not show image from above url, because orignally the path is -

http://localhost:8100/files/hydrocarbon_files/image001.gif

What should I do so that image loads locally as well?


Solution

  • ionic dont support external paths. you have to copy that image inside ionic projects's assets folder then it will work. E.G

    <img src="assets/img/imageName.png" >