Skip to content

Inline media block#968

Draft
busbyk wants to merge 5 commits intomainfrom
inline-media-block
Draft

Inline media block#968
busbyk wants to merge 5 commits intomainfrom
inline-media-block

Conversation

@busbyk
Copy link
Collaborator

@busbyk busbyk commented Mar 3, 2026

WIP

Remaining things to address:

  • The % width options aren't ideal since you might want an image to be 25% of the width on desktop but full width on mobile. We need a solution for that here. Similar problem in the MediaBlock discussed in Media block should use responsive image sizes based on it's container #757
  • Hydration error occurs for InlineMediaBlock
  • Needs to be added to lexical editors that specify a different list of blocks as the defaultLexical configuration -- currently only added to the Posts collection's lexical editor and the defaultLexical configuration
  • InlineMediaBlock needs a thumbnail

Description

Adds a new InlineMedia inline block for the Lexical rich text editor, allowing editors to embed images directly within text flow. Images can be positioned inline with configurable vertical alignment, or floated left/right with text wrapping.

Related Issues

None, alternative to #961

Key Changes

  • New InlineMedia block (src/blocks/InlineMedia/) — config and component for inline media in rich text
  • Position options: Inline (within text flow) or float left/right (text wraps around image)
  • Size options: Original (natural size), percentage widths (25%/50%/75%/100%), or fixed pixel height
  • Vertical alignment: Top, middle, bottom, or baseline (only for inline position)
  • Optional caption: Displayed below the image as small gray text
  • Registered in Posts collection and default Lexical editor config as an inlineBlock
  • RichText renderer updated with JSX converter for frontend rendering

How to test

  1. Run pnpm dev and navigate to the admin panel
  2. Create or edit a Post (or any content using the default Lexical editor)
  3. In the rich text editor, use the inline block inserter to add an "Inline Media" block
  4. Upload or select a media item and configure position, size, and alignment
  5. Verify:
    • Inline position: Image renders within the text line with correct vertical alignment
    • Float left/right: Image floats to the side with text wrapping around it
    • Size options: Percentage widths scale relative to the container; fixed height respects the pixel value
    • Caption: Appears as small text below the image when provided
  6. View the published content on the frontend to confirm the rich text JSX converter renders correctly

Screenshots / Demo video

https://www.loom.com/share/a167f8e500824d60b88914fe6b66014b

Hmm I wonder if floats are too confusing to content editors when they can use them, unconstrained in the ContentBlock?
image

Migration Explanation

No migration needed — this adds a new inline block type to existing Lexical rich text fields. Existing content is unaffected.

Future enhancements / Questions

  • Could extend to support inline video embeds
  • May want to add margin/padding controls for finer spacing adjustments around floated images

busbyk and others added 4 commits March 3, 2026 11:54
Introduces a new inline block for embedding images within rich text content.
Supports float left/right with text wrapping and inline positioning with
configurable vertical alignment. Registered in defaultLexical and Posts collection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ible caption

Replace small/medium/large presets with more flexible sizing options:
original, 25/50/75/100% container width, and fixed pixel height.
Caption now renders as visible text below the image instead of a tooltip.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Preview deployment: https://inline-media-block.preview.avy-fx.org

@busbyk busbyk self-assigned this Mar 7, 2026
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.

1 participant