diff --git a/lib/cache/image.ts b/lib/cache/image.ts index 9ebc154..2f92b3b 100644 --- a/lib/cache/image.ts +++ b/lib/cache/image.ts @@ -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, ); } diff --git a/lib/crud.ts b/lib/crud.ts index 11dd9f3..78d3eb5 100644 --- a/lib/crud.ts +++ b/lib/crud.ts @@ -24,12 +24,11 @@ export async function addThumbnailToResource( 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, }, }; }