Browse Source

Working: ordinary embeds, third-eye. [Not Tested]: pomf.

Merge branch 'feat-black-posts' into 中出し
Anonymous 2 years ago
parent
commit
add0d7bb19
  1. 16
      src/Embedding.svelte

16
src/Embedding.svelte

@ -44,16 +44,18 @@
if (settled) return if (settled) return
settled = true settled = true
if(file.thumbnail == null) return // media is to be either thumbnail or data
const thumb = typeof file.thumbnail === 'function' ? (await file.thumbnail()) : file.data;
// const thumb = file.thumbnail || file.data // const thumb = file.thumbnail || file.data
const media = typeof file.thumbnail === 'function' ? (await file.thumbnail()) : file.data;
if(media == null) return
let type: FileTypeResult | undefined let type: FileTypeResult | undefined
if (thumb instanceof Buffer) { if (media instanceof ArrayBuffer || media instanceof Uint8Array) {
type = await fileTypeFromBuffer(thumb); type = await fileTypeFromBuffer(media);
url = URL.createObjectURL(new Blob([thumb], { type: type?.mime })) url = URL.createObjectURL(new Blob([media], { type: type?.mime }))
// if (!type) return; // extracted out below for TypeScript // if (!type) return; // extracted out below for TypeScript
} else if (typeof thumb === 'string'){ } else if (typeof media === 'string'){
let head = headerStringToObject(await GM_head(thumb, undefined)) let head = headerStringToObject(await GM_head(media, undefined))
// TODO write a proper getExt() and getMime() // TODO write a proper getExt() and getMime()
type = { ext: '' as any, mime: head['content-type'].split(';')[0].trim() } type = { ext: '' as any, mime: head['content-type'].split(';')[0].trim() }
} }

Loading…
Cancel
Save