Skip to content

Commit 7281abd

Browse files
authored
chore: fix blabsy image issue (#441)
1 parent 2ab846e commit 7281abd

3 files changed

Lines changed: 57 additions & 15 deletions

File tree

platforms/blabsy/src/components/input/image-preview.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,34 @@ export function ImagePreview({
5656

5757
// Combine accidentally separated base64 images
5858
const processedImages = useMemo(() => {
59-
return combineBase64Images(imagesPreview);
59+
console.log('[ImagePreview] Raw images received:', {
60+
count: imagesPreview?.length || 0,
61+
images: imagesPreview?.map((img, i) => ({
62+
index: i,
63+
id: img.id,
64+
srcPreview: img.src.substring(0, 100),
65+
srcLength: img.src.length,
66+
alt: img.alt,
67+
type: img.type
68+
}))
69+
});
70+
71+
const processed = combineBase64Images(imagesPreview);
72+
73+
console.log('[ImagePreview] Processed images:', {
74+
originalCount: imagesPreview?.length || 0,
75+
processedCount: processed.length,
76+
processed: processed.map((img, i) => ({
77+
index: i,
78+
id: img.id,
79+
srcPreview: img.src.substring(0, 100),
80+
srcLength: img.src.length,
81+
alt: img.alt,
82+
type: img.type
83+
}))
84+
});
85+
86+
return processed;
6087
}, [imagesPreview]);
6188

6289
// Update previewCount based on processed images

platforms/blabsy/src/components/ui/next-image.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,33 @@ export function NextImage({
3636

3737
const handleLoad = (): void => setLoading(false);
3838

39+
// Check if the image source is a base64 data URI
40+
const isBase64 = typeof src === 'string' && src.startsWith('data:');
41+
42+
// For base64 images, use a regular img tag to avoid Next.js optimization issues
43+
if (isBase64) {
44+
return (
45+
<figure style={{ width }} className={className}>
46+
<img
47+
className={cn(
48+
imgClassName,
49+
loading
50+
? blurClassName ??
51+
'animate-pulse bg-light-secondary dark:bg-dark-secondary'
52+
: previewCount === 1
53+
? '!h-auto !min-h-0 !w-auto !min-w-0 rounded-lg object-contain'
54+
: 'object-cover',
55+
'w-full h-full'
56+
)}
57+
src={src}
58+
alt={alt}
59+
onLoad={handleLoad}
60+
/>
61+
{children}
62+
</figure>
63+
);
64+
}
65+
3966
return (
4067
<figure style={{ width }} className={className}>
4168
<Image

platforms/blabsy/src/lib/utils/image-utils.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export function combineBase64Images(
1717
id: string;
1818
}> = [];
1919

20-
console.log('Processing images for base64 combining:', images.length);
21-
2220
for (let i = 0; i < images.length; i += 2) {
2321
const dataPart = images[i];
2422
const chunkPart = images[i + 1];
@@ -31,11 +29,6 @@ export function combineBase64Images(
3129
) {
3230
// Combine the base64 parts
3331
const combinedSrc = `${dataPart.src},${chunkPart.src}`;
34-
console.log(`Combined base64 image at index ${i}:`, {
35-
original: dataPart.src.substring(0, 50) + '...',
36-
chunk: chunkPart.src.substring(0, 50) + '...',
37-
combined: combinedSrc.substring(0, 50) + '...'
38-
});
3932

4033
result.push({
4134
...dataPart,
@@ -49,20 +42,15 @@ export function combineBase64Images(
4942
} else {
5043
// Handle odd number of images (last item)
5144
if (dataPart) {
52-
if (dataPart.src.startsWith('data:')) {
53-
console.warn(
54-
`Incomplete base64 image at index ${i}, skipping`
55-
);
45+
if (dataPart.src.startsWith('data:') && !dataPart.src.includes(',')) {
46+
// Incomplete base64 image, skip it
5647
} else {
5748
result.push(dataPart);
5849
}
5950
}
6051
}
6152
}
6253

63-
console.log(
64-
`Processed ${images.length} images into ${result.length} valid images`
65-
);
6654
return result;
6755
}
6856

0 commit comments

Comments
 (0)