Skip to content

fix(theme-classic): set automatic width for markdown images - #12793

Closed
ShubhamReddy06 wants to merge 1 commit into
meta:mainfrom
ShubhamReddy06:fix/9462-markdown-image-distortion
Closed

ShubhamReddy06 wants to merge 1 commit into
meta:mainfrom
ShubhamReddy06:fix/9462-markdown-image-distortion

Conversation

@ShubhamReddy06

@ShubhamReddy06 ShubhamReddy06 commented Oct 29, 2026 •

Copy link
Copy Markdown

Motivation

Fixes #9462.

Images may have explicit width and height attributes generated by Docusaurus. The classic theme's Markdown image styles already include height: auto, but do not explicitly define width: auto.

This change adds width: auto alongside the existing height rule to allow the browser to calculate image dimensions while preserving the image's intrinsic aspect ratio.

Solution

Updated packages/docusaurus-theme-classic/src/theme/MDXComponents/Img/styles.module.css:

.img {
  height: auto;
  width: auto;
}

This is a minimal CSS change intended to improve image sizing behavior while retaining the existing component structure and API.

Test Plan

  • Verified image dimensions in a headless Chrome layout check using a 1600 × 900 image inside an 800px container; the image rendered at 800 × 450.
  • Ran git diff --check HEAD~1 successfully.
  • Full project tests were not run because dependencies were unavailable in the environment.

The original issue's specific reproduction has not yet been independently verified with this change.

Related Issues

Summary by CodeRabbit

  • Style
    • Images now use automatic width sizing, allowing their displayed width to adjust naturally within the page layout. This may change how images appear compared with the previous fixed-width behavior.

…(AI-assisted)

Add `width: auto` alongside `height: auto` in `MDXComponents/Img/styles.module.css`
to ensure images with generated dimensions scale proportionally.

Fixes meta#9462
@meta-cla

meta-cla Bot commented Oct 29, 2026

Copy link
Copy Markdown

Hi @ShubhamReddy06!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b982c0bb-0cd5-42b3-bd86-8c1aefc700dc
Commits

Reviewing files that changed from the base of the PR and between 4e6fe61 and 90f1e89.

Files selected for processing: 1
  • packages/docusaurus-theme-classic/src/theme/MDXComponents/Img/styles.module.css

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The .img style now sets width: auto.

Changes: Image style adjustment

Layer / File(s) Summary
Set image width to auto
packages/docusaurus-theme-classic/src/theme/MDXComponents/Img/styles.module.css
The .img style rule now sets width: auto.

Priority: Normal

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 90f1e

No actionable merge-blocking risk is established.

Architecture risk: Low · up to 90f1e

The change affects 1 system.

Changed systems: packages/docusaurus-theme-classic

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — packages/docusaurus-theme-classic (library) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in packages/docusaurus-theme-classic/src/theme/MDXComponents/Img/styles.module.css: Added width: auto to .img.
Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: setting automatic width for Markdown images in the classic theme.
Linked Issues check Passed Issue #9462 requests Markdown images that do not stretch because of generated dimensions. The reviewed stylesheet now sets .img { height: auto; width: auto; }. The supplied change summary identifies…
Out of Scope Changes check Passed The supplied whole-PR summary reports one added CSS declaration in packages/docusaurus-theme-classic/src/theme/MDXComponents/Img/styles.module.css. The declaration supports the linked image-sizing f…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

Issue #9462 requests Markdown images that do not stretch because of generated dimensions. The reviewed stylesheet now sets .img { height: auto; width: auto; }. The supplied change summary identifies no other implementation changes. This directly addresses the requested image sizing behavior. Issue #9462 defines no separate automated-test requirement.

Full details: Out of Scope Changes check

Explanation

The supplied whole-PR summary reports one added CSS declaration in packages/docusaurus-theme-classic/src/theme/MDXComponents/Img/styles.module.css. The declaration supports the linked image-sizing fix. No unrelated code, API, or component changes are shown.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Oct 29, 2026

Copy link
Copy Markdown

✅ [V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 90f1e89
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6ae310816e243ea99ff7b572
😎 Deploy Preview https://deploy-preview-12793--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@slorber slorber closed this Oct 29, 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.

Image distortion (stretching vertically)

2 participants