PeterStaev / nativescript-image-swipe

A NativeScript widget to easily :point_up_2: and :mag: through a list of images
Apache License 2.0
35 stars 21 forks source link

how to display image file from local storage? #19

Closed wiliarko closed 6 years ago

wiliarko commented 6 years ago

how to display image file from local storage?

i can't display image from local storage.

System.err: java.net.MalformedURLException: Protocol not found: ~/storage/emulated/0/DCIM/Camera/NSIMG_20171027_52440.jpg

PeterStaev commented 6 years ago

Hey @wiliarko , behind the scenes the plugin uses NativeScript's ImageCache module which works with URLs. So you need to use a URL and not file path (something like file://........).

wiliarko commented 6 years ago

thanks @PeterStaev it's work for me

Archi20 commented 6 years ago

Any more tips for this? I can't resolve similar issue :(

components.ts `
mapPath: string = "~/assets/images/" + environment.mapName; items: any[] = [];

ngOnInit() { 
    this.items.push({ file: this.mapPath });
}

`

.html `

`

For Random Url works fine, bu i need get image from file, any help?

PeterStaev commented 6 years ago

@Archi20 , see my comment above. This should be a URL not a path.

Archi20 commented 6 years ago

So it is impossible to use file-path with this plugin?

PeterStaev commented 6 years ago

You need to transform the file-path to file-url. Again see my first comment here. You can see what NS core class the plugin uses and in turn what that class supports.

sepccom commented 5 years ago

@PeterStaev are you able to provide an example using file://

For example, I am saving the edited image to /data/user/0/au.com.sepccom.pl/files/5628_updated.png

How do I push this back to the viewModel imageUrl field so that the existing image is replaced with the edited version?

Thanks,

PeterStaev commented 5 years ago

@sepccom , your url should look as any other file Url in nativecsript:

 file:///data/user/0/au.com.sepccom.pl/files/5628_updated.png

Also providing user specific examples is not part of the free support of this plugin. If you wish we offer paid support for all of my plugins and you can buy one here: https://www.tangrainc.com/subscriptions/