Skip to content

Commit 1e31f68

Browse files
committed
feat(Markdown.tsx): allow custom image dimensions in Markdown component
Add support for custom width and height attributes for images in the Markdown component. This change allows users to specify image dimensions directly in the Markdown content, providing greater flexibility and control over image rendering. Default dimensions are maintained for backward compatibility when width and height are not specified.
1 parent 0855e2b commit 1e31f68

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/components/global/Markdown.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ export default function Markdown({
6868
[rehypePrism, { ignoreMissing: true }],
6969
]}
7070
components={{
71-
img: ({ src, alt, className, ...props }) => {
71+
img: ({ src, alt, className, width, height, ...props }) => {
7272
return (
7373
<>
7474
<Image
7575
src={typeof src === "string" ? src : ""}
7676
alt={alt || ""}
77-
width={512}
78-
height={384}
77+
width={typeof width === "number" ? width : 512}
78+
height={typeof height === "number" ? height : 384}
7979
className={cn(
8080
"mx-auto max-w-(--breakpoint-md) cursor-pointer rounded-lg",
8181
className

0 commit comments

Comments
 (0)