fix: properly detect the mime type being passed
This commit is contained in:
@@ -3,8 +3,9 @@ import {
|
|||||||
launchImageLibraryAsync,
|
launchImageLibraryAsync,
|
||||||
MediaTypeOptions,
|
MediaTypeOptions,
|
||||||
} from 'expo-image-picker'
|
} from 'expo-image-picker'
|
||||||
import {getDataUriSize} from './util'
|
|
||||||
import * as Toast from 'view/com/util/Toast'
|
import * as Toast from 'view/com/util/Toast'
|
||||||
|
import {getDataUriSize} from './util'
|
||||||
|
|
||||||
export async function openPicker(opts?: ImagePickerOptions) {
|
export async function openPicker(opts?: ImagePickerOptions) {
|
||||||
const response = await launchImageLibraryAsync({
|
const response = await launchImageLibraryAsync({
|
||||||
@@ -26,7 +27,7 @@ export async function openPicker(opts?: ImagePickerOptions) {
|
|||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
.map(image => ({
|
.map(image => ({
|
||||||
mime: 'image/jpeg',
|
mime: image.mimeType || 'image/jpeg',
|
||||||
height: image.height,
|
height: image.height,
|
||||||
width: image.width,
|
width: image.width,
|
||||||
path: image.uri,
|
path: image.uri,
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ export async function pasteImage(
|
|||||||
uri: string,
|
uri: string,
|
||||||
): Promise<ComposerImageWithoutTransformation> {
|
): Promise<ComposerImageWithoutTransformation> {
|
||||||
const {width, height} = await getImageDim(uri)
|
const {width, height} = await getImageDim(uri)
|
||||||
|
const match = /^data:(.+?);/.exec(uri)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
alt: '',
|
alt: '',
|
||||||
@@ -98,7 +99,7 @@ export async function pasteImage(
|
|||||||
path: uri,
|
path: uri,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
mime: 'image/jpeg',
|
mime: match ? match[1] : 'image/jpeg',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user