Have a question similar to this one.
How do you save and load an image to and from localStorage
, a personalized cache, using plain JavaScript?
Have a question similar to this one.
How do you save and load an image to and from localStorage
, a personalized cache, using plain JavaScript?
For storing and retrieving image from local storage you can simply use javascript. Here is an example:
bannerImage = document.getElementById('bannerImg');
imgData = getBase64Image(bannerImage);
localStorage.setItem("imgData", imgData);
function getBase64Image(img) {
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
var dataURL = canvas.toDataURL("image/png");
return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
}