1

This is my code to save data locally, just run at the time; the user is out of network connection:

this.ngf.setItem('layouts', response);

In "response" I have everything saved correctly, but for the images, since their source attributes are external links, while the page is loading the images got an error.

Therefore, I think there might be a way to save the images locally with the local addressed, replaced with the external links in response array. So at the time of connection lost, they will be loaded locally through:

this.ng.getItem('layouts', response);

The problem is I don't know how to develop that idea, or if there is any other solution I would appreciate if you share it here!

Atanas
  • 366
  • 2
  • 17
Nazanin
  • 11
  • 1

1 Answers1

0

Maybe you could get the images in base64 encoding. Then store them (as base64 string) This post might help you: how-to-convert-image-into-base64-string-using-javascript

Hope it helps.

Community
  • 1
  • 1
  • I tried that, but it does not work for me, since the format to store the images should be the same as the way for being Online situation. I mean just storing the URL and use the as image's src attribute. However, I am up to save the images on the server and store their relative address. – Nazanin Jun 19 '18 at 05:54