Images disappear when updating app

I have this ionic app which saves some data as json objects to localstorage and then display it in the view.

This is the form of the object when console.logged:

 {
 name: Jon Doe,
age: 45,
img: file:///var/mobile.....tmp/cdv_photo_007.jpg

}
The image is added using the phone gap camera plugin. Everything works like charm, but when I installed an update of the app, the images doesn’t persist. All the other info in the locally stored objects, however, is still there.

I’m using the following code, taken straight from the ionic docs, to save the objects:

  projectService.save = function(projects) {
  
       window.localStorage['projects'] = angular.toJson(projects);

  }

Is there a problem with localStorage persisting or is the problem in the html, ie?

<img class="portrait" style="max-width: 100%;" src="{{activeProject.img}}">

All help much appreciated!

Hey there.

So the only way to store images in local storage is if you convert them to bas3-64 strings.

Oh boy, there’s always something :slight_smile: Thank’s!!

1 Like

I am having the same issue. Did it solve your problem to save them as base-64 strings?

Thank you!

you can try below, it’s work for me
<img src="img/qa/button.png">