Images are corrupted cordova?
Hello we are using ImgCache in App but some images appears corrupted,So is there any solution for this issue. Regards

here's our code:
useCachedFile: function (url, baseUrl) { ImgCache.isCached( baseUrl + url, function (path, success) { var img = $("[img-src='" + path + "']"); if (success) { // already cached console.log("used from cache"); ImgCache.getCachedFileURL(path, function (img_src, file_url) { console.log("found in cache"); $(img).attr('src', file_url); }) } else { // not there, need to cache the image $(img).attr('src', '/vendors/imageCache/placeholder.png'); ImgCache.cacheFile(baseUrl + url, function () { ImgCache.getCachedFileURL(baseUrl + url, function (img_src, file_url) { console.log("found in cache"); $(img).attr('src', file_url); }) }, function () { $(img).attr('src', baseUrl + url); }); } }); }
I guess this is the problem described in issue #76 : did you close the application / stop the cacheFile before it has time to download the files correctly?
no, you could see from the previous code that after we cache files we used the cached version, also due to compatibility we use cordova v2.9
What is the mobile operating system you're targeting?
Android version
A similar issue with Android: #84 . Can you target another OS to test? As reported in this issue, several problems with the file plugin for Android. Could you perhaps use a newer version of the file plugin while keeping your older cordova version?
Hello,
I have the same problem but this time on IOS, when the cache is empty and there are a lot of images which should be downloaded, cached and then displayed. Some of the images appear only partially.
ImgCache.isCached(url, function(path, success){ if(success){ console.log('util.js:preloadImage:Image ' + url + ' is cached. target: ' + target(imgId)); ImgCache.useCachedFileWithSource(target(imgId), url, function(){ if (aSize==1){imageResize(target(imgId), 64, 64);} } ); } else { console.log('util.js:preloadImage:Image ' + url + ' is NOT CACHED. target: ' + target(imgId)); ImgCache.cacheFile(url, function(){ ImgCache.useCachedFileWithSource(target(imgId), url, function(){ if (aSize==1){imageResize(target(imgId), 64, 64);} } ); }); } });
Thanks chrisben for your reply, for this issue its recommended to use the online version of the images at first time to avoid corruption. so in else case use to online version else { ImgCache.cacheFile(baseUrl + url, function () { $(img).attr('src', baseUrl + url); } another question is imageCaching working in WP 8
Indeed there should be no need to directly use the cached version of the files as soon as you have cached them, you can keep the online version. The cached images should only be used when offline mode is detected or if images fail to show up (see imagesloaded library).
Though doing it this way should be working too, but there must be some problem with the cordova file plugin returning too quickly before the cached file is fully written to the disk, thus this problem.
I have no idea about WP8, any feedback for this platform is welcome!
@mo3taz-abdallh from another post I've seen you use an old version of cordova, did you try a newer version to see if it fixes this download issue? Did you test ImgCache on Windows 8?