Skip to content

Cap rich description image width#366

Merged
progressions merged 1 commit into
masterfrom
feature/cap-description-image-width
Jan 29, 2026
Merged

Cap rich description image width#366
progressions merged 1 commit into
masterfrom
feature/cap-description-image-width

Conversation

@progressions

@progressions progressions commented Jan 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • cap rendered markdown images to container width with auto height
  • add ImageKit transform on RichDescription images to constrain width

Testing

  • npm test

Copilot AI review requested due to automatic review settings January 29, 2026 13:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the RichDescription component to cap markdown image widths for better rendering. It adds both CSS constraints (maxWidth: 100%, height: auto) and ImageKit CDN transforms to optimize image delivery at appropriate sizes.

Changes:

  • Added ImageKit URL transformation to inject width constraints (max 1200px) for ImageKit-hosted images
  • Implemented custom img renderer in ReactMarkdown with responsive CSS styling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +40 to +49
function addImagekitTransform(src: string): string {
if (!src.includes("ik.imagekit.io")) return src
if (src.includes("/tr:") || /[?&]tr=/.test(src)) return src

const match = src.match(/^(https?:\/\/ik\.imagekit\.io\/[^/]+\/)(.+)$/)
if (!match) return src

const [, base, path] = match
return `${base}${IMAGEKIT_TRANSFORM}/${path}`
}

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding documentation for this function similar to other helper functions in this file (e.g., capitalizeEntityType at line 36). The documentation should explain the transform parameters and the URL structure expected.

Copilot uses AI. Check for mistakes.
Comment on lines +245 to +255
img: ({ src, alt }) => {
if (!src) return null
return (
<Box
component="img"
src={addImagekitTransform(src)}
alt={alt || ""}
sx={{ maxWidth: "100%", height: "auto" }}
/>
)
},

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new image rendering functionality and the addImagekitTransform function lack test coverage. Similar UI components in this directory (Autocomplete, ColorPickerField, EntityLink) have comprehensive tests in the tests directory. Consider adding tests for the image transform logic, especially for edge cases like URLs with existing transforms, query parameters, and non-ImageKit URLs.

Copilot uses AI. Check for mistakes.
return entityType.charAt(0).toUpperCase() + entityType.slice(1)
}

function addImagekitTransform(src: string): string {

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name uses lowercase "imagekit" but the codebase consistently uses "ImageKit" with a capital K in comments and documentation (see src/lib/marketingImages.ts:4, src/types/media.ts:22, src/lib/client/mediaLibraryClient.ts:69). Consider renaming to "addImageKitTransform" for consistency.

Copilot uses AI. Check for mistakes.
@progressions progressions merged commit 9306d3f into master Jan 29, 2026
10 checks passed
@progressions progressions deleted the feature/cap-description-image-width branch January 29, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants