Skip to content

Image placeholders should use stored dimensions to reduce layout shift #62

@reddpy

Description

@reddpy

When images load in the editor, they start as a fixed 320x180 spinner placeholder, then jump to their actual dimensions once loaded. This causes layout shift (content below jumps around).

The ImageNode already serializes width and height — once a user has resized an image or it has loaded at least once, these values are in the JSON. The placeholder/spinner div should use these stored dimensions via inline style instead of the fixed CSS size.

Files:

  • src/components/editor/nodes/image-component.tsx — apply width/height to .image-placeholder div when available

Before:

<div className="image-placeholder">

After:

<div
  className="image-placeholder"
  style={width && height ? { width: `${width}px`, height: `${height}px` } : undefined}
>

Same for the error placeholder.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions