photoviewer icon indicating copy to clipboard operation
photoviewer copied to clipboard

How to use with local image

Open noveweb opened this issue 8 years ago • 6 comments

Hi, i want to use with local image like: PhotoViewer.show('img/plan.jpg', 'Plan');

It's possible?

Thanks!

noveweb avatar Jan 04 '16 11:01 noveweb

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

idmadj avatar Nov 26 '16 07:11 idmadj

Hi Im using the base 64 functionality but it crashes on some device. Is there another way around this?

JoelAH avatar May 04 '17 00:05 JoelAH

@JoelAH You might running into a memory issue depending on how large the image file is...

MT-- avatar Jul 08 '17 01:07 MT--

I used this as an alternative https://github.com/keensoft/FullScreenImage-Cordova-Plugin/blob/master/README.md

dpakthakur avatar Jul 31 '17 10:07 dpakthakur

Thanks @idmadj . Thanks what i needed for android.

cjchrist777 avatar Sep 06 '17 06:09 cjchrist777

This Code Works for Me!

this.file.readAsDataURL(this.file.applicationDirectory + "www/assets/imgs/", "1.jpg").
then((dataURL:string) => {this.photoViewer.show(dataURL)})

arulyan avatar May 04 '19 09:05 arulyan