Image will not show in Ionic View


#1

When I run “ionic serve -l” my image is displayed in safari. When I run “ionic upload” sync to latest and clear app data in ionic view app, my image is not displayed. This is what I have in my html file

img src="…/assets/images/icon.png"

If tried

img src="/assets/images/icon.png"

and

img src=“assets/images/icon.png”

nothing seems to work. What’s wrong here?


#2

I’m having the same problem in ionic 3. I see several posts complaining about the problem but no solutions or reasons given for the problem. Anyone know why this happens?


#3

Just figured this out by going through the github issues. I had been using a src path from my assets folder within {projectname}/src. Instead I needed to point to the path in my {projectname}/www folder. Then it became viewable in Ionic View and Ionic Serve


#4

@ChargerIIC I don’t fully understand your solution. I’ve tried several paths, all using the www folder. Path looks like www/assets/img/img.jpg

Everything shows on ionic lab, but does not show on ionic view. Tried 4 different variations of path, still no luck with the newest ionic view app. Any insights you can provide would be great! Thanks!


#5

Try

"./assets/etc..."

I recall seeing that as a solution somewhere in the forums. Could be a false memory but, maybe not.


#6

@jaydz Thanks for the help, but unfortunately that did not work either. Very odd that it will work in ionic lab but not in ionic view.


#7

Well, it can be 1 of 2 things (to my limited knowledge).

  1. When you use ionic lab or ionic serve, the assets folder’s location is relationally different in position than when it’s on a
    device. localhost get’s involved in the path, etc.

  2. I don’t actually know, but there was a solution to the same exact issue on the forums within the last month or so. I don’t
    know if it got marked as a solution, but if you scour for it, that might be the fix you need.