Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use with local image #11

Open
noveweb opened this issue Jan 4, 2016 · 6 comments
Open

How to use with local image #11

noveweb opened this issue Jan 4, 2016 · 6 comments

Comments

@noveweb
Copy link

noveweb commented Jan 4, 2016

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

It's possible?

Thanks!

@idmadj
Copy link

idmadj commented Nov 26, 2016

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

@JoelAH
Copy link

JoelAH commented May 4, 2017

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

@MT--
Copy link

MT-- commented Jul 8, 2017

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

@dpakthakur
Copy link

@cjchrist777
Copy link

Thanks @idmadj . Thanks what i needed for android.

@arulyan
Copy link

arulyan commented May 4, 2019

This Code Works for Me!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants