javascript - How can I cache image files locally with PhoneGap / Cordova? -
here's problem :
i making web/mobile app, using angularjs , cordova. offline purpose, use localstorage store data of app (json, parameters, , on).
the thing : need store / cache images locally (again, offline purpose). as localstorage size limit around 5mo, can't use it, need more.
i thought use cache manifest, doesn't work, need update regulary, without recompiling app (i thought put cache manifest on external server, it's can't use cache manifest domain).
so i'm thinking of using cordova/phonegap file api, i have no idea achieve that...
any or ideas ?
after long hours searching on , github, found imgcache.js, js library handle file cache chrome, android , ios (through cordova).
https://github.com/chrisben/imgcache.js/
then, :
var target = $('.cached-img'); imgcache.iscached(target.attr('src'), function(path, success){ if(success){ // cached imgcache.usecachedfile(target); } else { // not there, need cache image imgcache.cachefile(target.attr('src'), function(){ imgcache.usecachedfile(target); }); } });
Comments
Post a Comment