0

android not support selecting multiple images using react-native-image-crop-picker , how to fixed it ?

enter code here

` handlePickImage = async () => { try {

        console.log('hit')
        const images = await ImagePicker.openPicker({
            width: 1000,
            height: 1000,
            cropping: true,
            multiple: true,
            compressImageQuality: 0.5,

        })
        console.log(images)

        for (const image of images) {
            const path = image.path.split('/');
            const fileName = path[path.length - 1]
            console.log('fileNameforVideo', fileName)
            this.setState(
                {
                    files: [... this.state.files, { url: '', type: image.mime.split('/')[0], path: image.path }],
                    file: image.path,
                    fileName,
                    filetype: image.mime.split('/')[0],
                    mimeType: image.mime
                })


            await this.getSingedUrl();
        }

    } catch (error) {

        console.log(error)
        console.log('lol')
    }

` thanks in advance

Riaz Ali
  • 81
  • 2
  • 4

2 Answers2

1

Currently, it is possible in the following ways.

ImagePicker.openPicker({
            multiple: true,
            compressImageQuality: 0.5,

        }).then(async images => {
        const result = [];

        for await (const image of images) {
            const img = await ImagePicker.openCropper({
                mediaType: "photo",
                path: image.path,
                width: 1000,
                height: 1000,
            });
            result.push(img.path);
        }

        return result;
    });
hong developer
  • 13,291
  • 4
  • 38
  • 68
0

I am not sure if I understand correctly the issue you are experiencing, but the library you are using has a note in their docs that says:

"Android: The prop 'cropping' has been known to cause videos not to be display in the gallery on Android. Please do not set cropping to true when selecting videos."

(link to the library README here)

You seem to be setting the multiple option correctly, but I noticed you have cropping set to true, which may be the cause of your issue. I hope that helps!

p-syche
  • 575
  • 1
  • 5
  • 17