I’ve seen this question partially asked before. Where do we put images and how do we access it in code? The answer for that seems to be in www/build/img and and access it in files using a relative path.
So I did that and it seems to work a bit. I manually created a folder www/build/img and put my files there. However that gets erased every time I restart ionic serve.
So what is the right way to put the file there? Is there a consistent/suggested way (maybe gulp entries) to copy the images over correctly on each build? (Also, if it is there, why isn’t it in the default project created by ionic start?
Put it under www/images or www/assets/images/ and commit it into git, in android refer to image as src='./images/img.png' or src='./assets/images/img.png' I haven’t tried iOS.
Just to add to this, you’ll want to reference all images path as if they were relative to the index.html.
Since index.html will actually load all the content, all paths must be relative to that.
Also, when running on the device, be carful with the / in front of the path.
Android and iOS handle that differently and could make it seem like the image path is on the native device and not local to the folder.
Absolutely agree… terrible documentation and sporadic behaviour when it comes to copying images over during ionic serve… sometimes it works… sometimes doesn’t … hours(!) wasted.