Ionic 4 Select Multiple Image From Gallery With Image-picker Not Working
I Use Image-Picker for select multiple Image From Gallery But I Get The 'Plugin_not_installed' I Use From link To Install plugin ionic image picker ionic cordova plugin add cordova
Solution 1:
You can use
https://ionicframework.com/docs/native/image-picker
ionic cordova plugin add cordova-plugin-telerik-imagepicker
npm install @ionic-native/image-picker
* `cordova plugin add cordova-android-support-gradle-release`
* `ioinc cordova platform rm android`
* `ionic cordova platform add android`
* `ionic cordova build android --prod`import { ImagePicker, ImagePickerOptions } from'@ionic-native/image-picker/ngx';
constructor(private imagePicker: ImagePicker) { }
getPictures() {
letoptions: ImagePickerOptions = {
//here Quality of images, defaults to 100 quality: 100,
//here Width of an Image width: 600,
//here Height of an Image height: 600,
/** Output type, defaults to 0 (FILE_URI).
* FILE_URI :0 (number) it returns a actual path for an image
*/outputType: 1//here Maximum image count for selection, defaults to 15. //while setting a number 15 we can load 15 images in one selection.maximumImagesCount: 8// max images to be selected, defaults to 15. If this is set to 1
};
this.imagePicker.getPictures(options)
.then(selectedImg => { })
}
Solution 2:
try using the plugin in a non-native way. In your component declare a window variable and then use it to call the plugin. You need to test it from a device, it's not working on browsers, neither on --devapp serve. It will work fine, but it isn't taking the options object... I need it to return base64 (outputType: 1), but always returns fileURI
/*Imports section*/declareconstwindow: any;
@Component({...})
exportclassHomePageimplementsOnInit {
constructor(){}
yourMethod() {
window.imagePicker.getPictures(
asyncfunction(results) {
for (var i = 0; i < results.length; i++) {
const currentPicture = results[i];
files.push(currentPicture);
}
console.log(files);
}, function (error) {
console.log('Error: ' + error);
},
{
outputType: 1,
maximumImagesCount: 30,
quality: 100
}
);
}
}
Post a Comment for "Ionic 4 Select Multiple Image From Gallery With Image-picker Not Working"