Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): size the chat image slot from server-reported dimensions #10200

Mergedjuliusmarmingemerged 3 commits intomedia-dims/mobile fromrefs/pull/10200/headmerged by juliusmarminge View on GitHub

Showing 3 changed files with 67 additions and 5 deletions.

x
0 of 3 viewed, 3 left
1 addition and 1 deletionapps/web/src/components/chat/MessagesTimeline.tsxModified
View file
@@ -3342,7 +3342,7 @@
alt={viewedImage.alt}
srcFragment={viewedImage.srcFragment}
workspaceRoot={workspaceRoot}
- style={{ maxHeight: "16rem" }}
+ maxHeightRem={16}
onImageExpand={onImageExpand}
</div>
22 additions and 2 deletionsapps/web/src/components/ChatMarkdown.tsxModified
View file
@@ -1235,9 +1235,15 @@
return `![${escapedAlt}](${src}${titleSuffix})`;
+/**
+ * `maxHeightRem` folds a height cap into the width bound: `max-height` alone
+ * would not feed back through `aspect-ratio` once `width` is definite, so a
+ * tall image would keep a box wider than the picture it draws.
+ */
function authoredImageSizeStyle(
width: string | number | undefined,
height: string | number | undefined,
+ maxHeightRem = 30,
): CSSProperties | undefined {
const parsedWidth = Number(width);
const parsedHeight = Number(height);