Does PhotoViewer accept img from local? like this:
html:
<button ion-button (click)="goImage()">View</button>
ts file:
goImage() {
this.photoViewer.show('../assests/img/mapping.jpg');
}
Does PhotoViewer accept img from local? like this:
html:
<button ion-button (click)="goImage()">View</button>
ts file:
goImage() {
this.photoViewer.show('../assests/img/mapping.jpg');
}
Per documentation, the show
method requires a url
to show an image:
https://ionicframework.com/docs/native/photo-viewer/#show
The Cordova plugin at https://github.com/sarriaroman/photoviewer also says:
This plugin is intended to show a picture from an URL into a Photo Viewer with zoom features.
But as the local file is also accessible via a local file URL, it may very well be possible to give this to the method - but you have to find out the local file URL first. No idea how to do this.
Alternatively you can see if you maybe using a data URI also works for this plugin. Then you only have to read the file locally.
Any idea how I can implement button that once clicked will open an Image?
I had a look at the Android source code of the Cordova plugin, and you can use http
, file
and data:image
(which is a base64 string of the image data) URLs. The last both options should be doable.