Fix video aspect ratio error - "Record/embed/aspectRatio/width cannot be less than 1" (#8571)
This commit is contained in:
+16
-4
@@ -333,15 +333,27 @@ async function resolveMedia(
|
|||||||
return {lang: caption.lang, file: data.blob}
|
return {lang: caption.lang, file: data.blob}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// lexicon numbers must be floats
|
||||||
|
const width = Math.round(videoDraft.asset.width)
|
||||||
|
const height = Math.round(videoDraft.asset.height)
|
||||||
|
|
||||||
|
// aspect ratio values must be >0 - better to leave as unset otherwise
|
||||||
|
// posting will fail if aspect ratio is set to 0
|
||||||
|
const aspectRatio = width > 0 && height > 0 ? {width, height} : undefined
|
||||||
|
|
||||||
|
if (!aspectRatio) {
|
||||||
|
logger.error(
|
||||||
|
`Invalid aspect ratio - got { width: ${videoDraft.asset.width}, height: ${videoDraft.asset.height} }`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
$type: 'app.bsky.embed.video',
|
$type: 'app.bsky.embed.video',
|
||||||
video: videoDraft.pendingPublish.blobRef,
|
video: videoDraft.pendingPublish.blobRef,
|
||||||
alt: videoDraft.altText || undefined,
|
alt: videoDraft.altText || undefined,
|
||||||
captions: captions.length === 0 ? undefined : captions,
|
captions: captions.length === 0 ? undefined : captions,
|
||||||
aspectRatio: {
|
aspectRatio,
|
||||||
width: videoDraft.asset.width,
|
|
||||||
height: videoDraft.asset.height,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (embedDraft.media?.type === 'gif') {
|
if (embedDraft.media?.type === 'gif') {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
ImagePickerAsset,
|
type ImagePickerAsset,
|
||||||
launchImageLibraryAsync,
|
launchImageLibraryAsync,
|
||||||
UIImagePickerPreferredAssetRepresentationMode,
|
UIImagePickerPreferredAssetRepresentationMode,
|
||||||
} from 'expo-image-picker'
|
} from 'expo-image-picker'
|
||||||
|
|||||||
Reference in New Issue
Block a user