chrisben / imgcache.js

JS library based on the File API to cache images for offline recovery (target: cordova/phonegap & chrome)
Other
826 stars 216 forks source link

Cordova useCachedFile(target): "File loaded from cache" but image is empty, dimensions are correct #224

Closed Tornister closed 6 years ago

Tornister commented 6 years ago

When I use usedCachedFile on my image element, I get a success log in the console: INFO: File l5c01_84.jpg loaded from cache

The DOM element then looks like this: < img id="cardModal-image" src="cdvfile://localhost/persistent/imgcache/f4598a3a963fbfb33ceb95edd9afe78923fc400f.jpg" data-old-src="http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_84.jpg" >

But apparently, the link cdvfile://localhost/persistent/imgcache/f4598a3a963fbfb33ceb95edd9afe78923fc400f.jpg only refers to an empty image with the correct height and width.

I'm helpless, is this a bug?

Tornister commented 6 years ago

It wasn't a problem with imgcache itself, but with the CSP settings. These finally worked:

< meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: cdvfile: https://ssl.gstatic.com 'unsafe-eval' 'unsafe-inline' https: http: wss: ws:; style-src 'self' 'unsafe-inline'; img-src filesystem: cdvfile: data:; media-src blob:" / >