Merge pull request #3201 from bluesky-social/samuel/handle-invalid-files
Filter out non-image files from image pickerzio/stable
commit
44b3a37f65
|
@ -18,11 +18,18 @@ export async function openPicker(opts?: ImagePickerOptions) {
|
|||
Toast.show('You may only select up to 4 images')
|
||||
}
|
||||
|
||||
return (response.assets ?? []).slice(0, 4).map(image => ({
|
||||
mime: 'image/jpeg',
|
||||
height: image.height,
|
||||
width: image.width,
|
||||
path: image.uri,
|
||||
size: getDataUriSize(image.uri),
|
||||
}))
|
||||
return (response.assets ?? [])
|
||||
.slice(0, 4)
|
||||
.filter(asset => {
|
||||
if (asset.mimeType?.startsWith('image/')) return true
|
||||
Toast.show('Only image files are supported')
|
||||
return false
|
||||
})
|
||||
.map(image => ({
|
||||
mime: 'image/jpeg',
|
||||
height: image.height,
|
||||
width: image.width,
|
||||
path: image.uri,
|
||||
size: getDataUriSize(image.uri),
|
||||
}))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue