natysoz / expo-images-picker

Multiple Asset Photos Videos selecting package for Expo SDK
MIT License
95 stars 35 forks source link

Proposal to store id and other data in returned data object from resize method. #49

Closed eric-personal closed 2 years ago

eric-personal commented 2 years ago

Hi all working on this project. First off thank you for all the work you have done on this amazing package. I've been playing around with the package and noticed the data returned from the resize method has none of the the original data which can be useful to know along with the new resized data. Particularly the original id which I use for React keys when rendering all the images in a FlatList. So I'm proposing something like this and wanted to see how you all felt.

In the manipulateResults() function in AssetsSelector.tsx where the resize code is run I'd like to spread the asset props into modAssets[{}]. Example:

          if (Resize) {
                let modAssets: (ImageManipulator.ImageResult &
                    MediaLibrary.Asset)[] = []
                await asyncForEach(selectedAssets, async (asset: Asset) => {
                    if (asset.mediaType === 'photo') {
                        const resizedImage = await resizeImages(asset, Resize)
                        modAssets.push({
                            ...asset,
                            ...resizedImage,
                        })

                    } else modAssets.push(asset)
                })

This now returns all the prior data along with the new resize data ?

natysoz commented 2 years ago

ill add this option