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

Can I use in meteor balze template(space bar)? #162

Closed Micjoyce closed 6 years ago

Micjoyce commented 8 years ago

I use like this

@cacheImageByRemoteUrl = (imgUrl)->
    ImgCache.isCached imgUrl, (path, success)->
        if success
            ImgCache.getCachedFileURL imgUrl, (originUrl, cacheUrl)->
                return cacheUrl
            , (error) ->
                toastr.error error
                return
        else
            ImgCache.cacheFile imgUrl, (cacheUrl) ->
                return cacheUrl
            , (error) ->
                toastr.error error
                return imgUrl

            return imgUrl
Blaze.registerHelper 'cacheImageByRemoteUrl', cacheImageByRemoteUrl

and use in html (url is a img src url) {{cacheImageByRemoteUrl url}} but when at chrome develope tool,Img tags has't attritube src Hope someone can help me or give me some advice!!!

chrisben commented 8 years ago

Enable debug logging in imgcache with :

ImgCache.options.debug = true;

then check your console.

Are you sure ImgCache.init has been called first? You could use the qimgcache.js promise version, it will automatically first call init if needed.