NativeScript / nativescript-fresco

This repository holds the NativeScript plugin that exposes the functionality of the Fresco image library to NativeScript developers.
Apache License 2.0
53 stars 23 forks source link

Allow imageUri to load local images #22

Closed triniwiz closed 8 years ago

Daxito commented 8 years ago

@triniwiz is it possible to add this other condition as well? I have this image but I know the full path already and this image is not at the Root folder, so we just need to remove the "~"

} else if (this.imageUri.startsWith("/")) { uri = android.net.Uri.parse('file:' + this.imageUri); }

triniwiz commented 8 years ago

@Daxito will update :)

VladimirAmiorkov commented 8 years ago

@Daxito can you give me an example of the full path you would like to use as imageUri, how would this path look like in the XML?

Daxito commented 8 years ago

@VladimirAmiorkov I have this app that takes pictures or displays pictures using CDN, so I need to display them (with fresco), so when I take a picture using the "nativescript-imagepicker" plugin I get back an ImageSource that then I save in my local storage (I have to save it to my local storage as well) like:

var fs = require("file-system"); var documents = fs.knownFolders.documents(); var folder = documents.getFolder("roofImageCache");

var saveToLocal = function (imageSource) { let path = fs.path.join(folder.path, 'picture.png'); return { saved: imageSource.saveToFile(path, enumsModule.ImageFormat.png), filePath: path }; }

What I get back is something like "/data/0/user/something/something/files/roofImageCache/picture.png" My xml looks with no difference between setting Url or local path, sometimes I need to set URL and sometimes local path for some pictures.