I believe one of two things have to happen. Either you have it put the folder in the www folder and reference in relation to the index file or adjust your gulp file to copy the file during the build process. I simply up a IMG folder at the root for www folder and used "IMG/image.png.
As I read few articles and topics related to ionic2, in which they mentioned to keep your images in project level 'www' folder…
which is a good practice…
create folder name as img in project level www folder…
path for the same are YOUR_PROJECT_NAME/www/img… keep your all images here…
and give path to your images in img tag as follows:
<img src="../../../img/company_logo.png">
This works for me…and this is standard practice too…
EDIT:
when your image is located in www/img then you should reference it as img/key.png from your HTML files or as ../../img/key.png from your SCSS files.
I am getting some behavior I do not understand. When I test my app in a browser by running ionic serve --livereload, it works fine, and I can see the image:
../../../images/blank-profile-picture.png
However, when I do cordova build, and install the apk on a device, I cannot see the image.
What should the path be? Is the ionic serve directory structure different to the final packaged apk structure?
when your image is located in www/img
– then you should reference it as img/logo.png from your HTML files
– or as ../../img/logo.png from your SCSS files.
this worked properly on my iPad and iPhone5. Try this one…this will work on both ionic serve and real devices
As I already mentioned approach in above reply (edited one), refer this forum answer by one of the ionic team member:
@richardmarais I Think a better solution will be to add a gulp task and that way you will avoid all the ../../../../
var copyResources = function() { return gulp.src('app/resources/**/*') .pipe(gulp.dest('www/build/resources')); };
Then add that to the build process. And now can place the images or any other resource under the resources folder and use in the code 'build/resources/.....'