feat: display thumbnail on feed

This commit is contained in:
codytseng
2024-11-10 12:14:59 +08:00
parent af04aed6e8
commit 6821b92e63

View File

@@ -32,7 +32,7 @@ export default function ImageGallery({
<img
className={`rounded-lg max-w-full cursor-pointer ${size === 'small' ? 'max-h-[15vh]' : 'max-h-[30vh]'}`}
key={index}
src={src}
src={getThumbUrl(src)}
onClick={(e) => handlePhotoClick(e, index)}
/>
)
@@ -53,3 +53,13 @@ export default function ImageGallery({
</div>
)
}
function getThumbUrl(url: string) {
if (url.startsWith('https://image.nostr.build/')) {
return url.replace('https://image.nostr.build/', 'https://image.nostr.build/thumb/')
}
if (url.startsWith('https://i.nostr.build/')) {
return url.replace('https://i.nostr.build/', 'https://i.nostr.build/thumb/')
}
return url
}