refactor: store thumbhash as stirng
This commit is contained in:
parent
0f3f64d118
commit
d4db8430e4
7
lib/cache/image.ts
vendored
7
lib/cache/image.ts
vendored
@ -54,7 +54,9 @@ export function createThumbhash(
|
||||
);
|
||||
if (!bytes) return;
|
||||
const hash = generateThumbhash(bytes, _image.width, _image.height);
|
||||
|
||||
if (hash) {
|
||||
const b64 = btoa(String.fromCharCode(...hash));
|
||||
cache.set(
|
||||
getCacheKey({
|
||||
url,
|
||||
@ -62,9 +64,9 @@ export function createThumbhash(
|
||||
width: _image.width,
|
||||
height: _image.height,
|
||||
}),
|
||||
hash,
|
||||
b64,
|
||||
);
|
||||
res(hash);
|
||||
res(b64);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -96,7 +98,6 @@ export function getThumbhash({ url }: { url: string }) {
|
||||
width: 200,
|
||||
height: 200,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,11 @@ export async function addThumbnailToResource<T = Resource>(
|
||||
if (!imageUrl) return res;
|
||||
const thumbhash = await getThumbhash({ url: imageUrl });
|
||||
if (!thumbhash) return res;
|
||||
const base64String = btoa(String.fromCharCode(...thumbhash));
|
||||
return {
|
||||
...res,
|
||||
meta: {
|
||||
...res?.meta,
|
||||
thumbnail: base64String,
|
||||
thumbnail: thumbhash,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user