fix aspect ratio error

This commit is contained in:
Samuel Newman
2025-06-26 11:48:05 +03:00
parent e5f9377a69
commit a4507dff8e
2 changed files with 11 additions and 5 deletions
+10 -4
View File
@@ -333,15 +333,21 @@ async function resolveMedia(
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
return {
$type: 'app.bsky.embed.video',
video: videoDraft.pendingPublish.blobRef,
alt: videoDraft.altText || undefined,
captions: captions.length === 0 ? undefined : captions,
aspectRatio: {
width: videoDraft.asset.width,
height: videoDraft.asset.height,
},
aspectRatio,
}
}
if (embedDraft.media?.type === 'gif') {
+1 -1
View File
@@ -1,5 +1,5 @@
import {
ImagePickerAsset,
type ImagePickerAsset,
launchImageLibraryAsync,
UIImagePickerPreferredAssetRepresentationMode,
} from 'expo-image-picker'