Skip to content

Commit b621cae

Browse files
committed
Update AttachmentsBar.tsx
1 parent 39466a4 commit b621cae

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

apps/twig/src/renderer/features/message-editor/components/AttachmentsBar.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ function FrozenGifThumbnail({ src, alt }: { src: string; alt: string }) {
1313
img.onload = () => {
1414
const canvas = canvasRef.current;
1515
if (!canvas) return;
16-
canvas.width = img.naturalWidth;
17-
canvas.height = img.naturalHeight;
16+
const size = 56;
17+
canvas.width = size;
18+
canvas.height = size;
1819
const ctx = canvas.getContext("2d");
1920
if (!ctx) return;
20-
ctx.drawImage(img, 0, 0);
21+
const min = Math.min(img.naturalWidth, img.naturalHeight);
22+
const sx = (img.naturalWidth - min) / 2;
23+
const sy = (img.naturalHeight - min) / 2;
24+
ctx.drawImage(img, sx, sy, min, min, 0, 0, size, size);
2125
};
2226
img.src = src;
2327
}, [src]);
2428

2529
return (
26-
<canvas
27-
ref={canvasRef}
28-
aria-label={alt}
29-
className="size-3.5 rounded-sm object-cover"
30-
/>
30+
<canvas ref={canvasRef} aria-label={alt} className="size-3.5 rounded-sm" />
3131
);
3232
}
3333

0 commit comments

Comments
 (0)