photoviewer
photoviewer copied to clipboard
How to use with local image
Hi, i want to use with local image like: PhotoViewer.show('img/plan.jpg', 'Plan');
It's possible?
Thanks!
On iOS, first add the cordova-plugin-file plugin (cordova plugin add cordova-plugin-file
), then:
declare var cordova: any;
PhotoViewer.show(cordova.file.applicationDirectory + "www/image.jpg");
On Android, the URL returned by applicationDirectory
won't work with PhotoViewer, but you can probably use File.readAsDataURL
and pass the output string to PhotoViewer.show
to leverage the base64 functionality.
Something like :
File.readAsDataURL(cordova.file.applicationDirectory + "www/", "image.jpg")
.then((dataURL:string) => {PhotoViewer.show(dataURL)})
See https://github.com/apache/cordova-plugin-file
Hi Im using the base 64 functionality but it crashes on some device. Is there another way around this?
@JoelAH You might running into a memory issue depending on how large the image file is...
I used this as an alternative https://github.com/keensoft/FullScreenImage-Cordova-Plugin/blob/master/README.md
Thanks @idmadj . Thanks what i needed for android.
This Code Works for Me!
this.file.readAsDataURL(this.file.applicationDirectory + "www/assets/imgs/", "1.jpg").
then((dataURL:string) => {this.photoViewer.show(dataURL)})