fix: remove forced 4/3 aspect ratio and dark background from image containers
Images now size naturally within max constraints instead of being letterboxed into a 4/3 bg-surface-input container. Fixes dark bars on GIFs and images whose aspect ratio doesn't match 4/3.
This commit is contained in:
@@ -187,14 +187,11 @@ function buildComponents(): Components {
|
|||||||
|
|
||||||
// Images (in markdown content — not attachments)
|
// Images (in markdown content — not attachments)
|
||||||
img: ({ src, alt }) => (
|
img: ({ src, alt }) => (
|
||||||
<div
|
<div className="mt-1 max-w-[400px]">
|
||||||
className="mt-1 rounded-md overflow-hidden bg-surface-input"
|
|
||||||
style={{ aspectRatio: '4/3', maxWidth: 400, maxHeight: 300 }}
|
|
||||||
>
|
|
||||||
<img
|
<img
|
||||||
src={src}
|
src={src}
|
||||||
alt={alt ?? ''}
|
alt={alt ?? ''}
|
||||||
className="w-full h-full object-contain"
|
className="max-w-full max-h-[300px] rounded-md"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
referrerPolicy="no-referrer"
|
referrerPolicy="no-referrer"
|
||||||
crossOrigin="anonymous"
|
crossOrigin="anonymous"
|
||||||
|
|||||||
@@ -346,14 +346,11 @@ export function Message({ message, isCompact, isFirstInGroup, previousMessageId
|
|||||||
) : (
|
) : (
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
{isGifOnly ? (
|
{isGifOnly ? (
|
||||||
<div
|
<div className="mt-1 max-w-[250px]">
|
||||||
className="mt-1 max-w-[250px] rounded-lg overflow-hidden bg-surface-input"
|
|
||||||
style={{ aspectRatio: '4/3', maxHeight: 250 }}
|
|
||||||
>
|
|
||||||
<img
|
<img
|
||||||
src={message.content!.trim()}
|
src={message.content!.trim()}
|
||||||
alt="GIF"
|
alt="GIF"
|
||||||
className="w-full h-full object-contain rounded-lg"
|
className="max-w-full max-h-[250px] rounded-lg"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,16 +10,12 @@ export function ImageEmbed({ embed }: ImageEmbedProps) {
|
|||||||
const openImagePreview = useUIStore((s) => s.openImagePreview);
|
const openImagePreview = useUIStore((s) => s.openImagePreview);
|
||||||
const imageUrl = embed.image ?? embed.url;
|
const imageUrl = embed.image ?? embed.url;
|
||||||
|
|
||||||
const style: React.CSSProperties = embed.width && embed.height
|
|
||||||
? { aspectRatio: `${embed.width}/${embed.height}`, maxWidth: Math.min(embed.width, 400), maxHeight: 300 }
|
|
||||||
: { aspectRatio: '4/3', maxWidth: 400, maxHeight: 300 };
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mt-2 rounded-lg overflow-hidden bg-surface-input" style={style}>
|
<div className="mt-2 max-w-[400px]">
|
||||||
<img
|
<img
|
||||||
src={imageUrl}
|
src={imageUrl}
|
||||||
alt={embed.title ?? ''}
|
alt={embed.title ?? ''}
|
||||||
className="w-full h-full object-contain rounded-lg cursor-pointer hover:opacity-90 transition-opacity"
|
className="max-w-full max-h-[300px] rounded-lg cursor-pointer hover:opacity-90 transition-opacity"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
referrerPolicy="no-referrer"
|
referrerPolicy="no-referrer"
|
||||||
onClick={() => openImagePreview(imageUrl)}
|
onClick={() => openImagePreview(imageUrl)}
|
||||||
|
|||||||
Reference in New Issue
Block a user