diff --git a/src/image-response/components/ImagePhotoGrid.tsx b/src/image-response/components/ImagePhotoGrid.tsx index f1b893a7..385e4012 100644 --- a/src/image-response/components/ImagePhotoGrid.tsx +++ b/src/image-response/components/ImagePhotoGrid.tsx @@ -7,6 +7,7 @@ import { doAllPhotosHaveOptimizedFiles, getOptimizedPhotoUrl, } from '@/photo/storage'; +import { fetchBase64ImageFromUrl } from '@/utility/image'; export default async function ImagePhotoGrid({ photos, @@ -53,7 +54,24 @@ export default async function ImagePhotoGrid({ const doOptimizedFilesExist = await doAllPhotosHaveOptimizedFiles(photos); - const renderPhoto = ({ id, url }: Photo, width: number, height: number) => + const photoData = await Promise.all(photos.map(async ({ id, url }) => { + const data = await fetchBase64ImageFromUrl( + getOptimizedPhotoUrl({ + imageUrl: url, + size: nextImageWidth, + addBypassSecret: IS_PREVIEW, + compatibilityMode: !doOptimizedFilesExist, + }), + { mode: 'no-cors' }, + ); + return { id, data }; + })); + + const renderPhoto = ( + { id, data }: typeof photoData[number], + width: number, + height: number, + ) =>