How to show photos from the camera album with the Cordova camera plugin?

Asked

Viewed 788 times

2

I have a mobile app, what I want to know and do is:

I have a modal that when opened I want to appear the photos I have on the device (in this case on the camera roll) and but show in a div I already have. How can I do that ?

2 answers

0

It is possible to access the photo library and choose 1 photo with the phonegap camera plugin, but not list all photos

The code below opens the mobile library and allows you to choose a photo, returning its location:

var cameraPopoverHandle = navigator.camera.getPicture(onSuccess, onFail, { destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
popoverOptions: new CameraPopoverOptions(300, 300, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY)

});

  • But I’ve seen an app that lists all the photos without accessing the library

  • It is not native sera?

  • I don’t know if you know the mockery and that’s the app

0

Well I had problem to try to open the gallery or use the Cordova’s camera plugin, the problem was not relating to the camera plugin, but with the compat plugin, using recommendations I found, to force its removal and install version 1.1.0.

To avoid problems, I also removed the plugin from the camera, and added again.

cordova plugin rm cordova-plugin-camera --save

cordova plugin add cordova-plugin-camera --save

cordova plugin remove cordova-plugin-compat --force --
save

cordova plugin add [email protected] --save

Using the method presented by @mauroneto, it worked perfectly.

var cameraPopoverHandle = navigator.camera.getPicture(
      function(onSuccess){
        console.log(onSuccess);
      },
      function(onFail){
        console.error(onFail);
      },
      {
        destinationType: Camera.DestinationType.FILE_URI,
        sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
        popoverOptions: new CameraPopoverOptions(
          300, 300, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY
        )
      }
    );

Browser other questions tagged

You are not signed in. Login or sign up in order to post.