I am confusing about putting images. In src folder, it has folder call assets and then img. I put images there. It worked in browser but app
ref: Images not loading in mobile from this post I put images in www/assets/img. It worked in app but the browsers
I declared it like this:
background-image: url("../assets/img/intro.png");
put it in
src/assets/img
when you build , it will copy to “www”
It should work in both browser and app.
This is how I am using images in my project -
- All images are in
src/assets/img
. - In the
.scss
file of any pagebackground-image: url("../assets/img/myImage.png");
.
If it still doesn’t works, try adding !important
after css property like background-image: url("../assets/img/intro.png") !important;
ùnortunatly, when building I did not see any images. Something wrong with
my ionic? could you help me to show how to manual build or trigger the
build. I did deleted all images in www once
Keep your all images in src/assets/img
.
Which command you are using to build?
Have you added device platform into your project using ionic cordova platform add android/ios
. (“android” and “ios” are separate).
After this command, use ionic cordova build android/ios
.
I see, I always use --release is that the problem I can not see it in www.
Thank you so much for helping
You can also try ionic cordova build android/ios --prod
. Ionic will build this one keeping produnction in mind.
You can try ionic cordova build android/ios --prod --release
too.
You can emulate too (android studio) - ionic cordova run android --prod
("–prod" is optional).
Out of curiosity, why cant they just be put straight into the imgs folder in www? It took me a while to figure out that you don’t put them in there, but I don’t know the reason why.