Repository navigation
🐛 fix: clamp rendered image max width to the container - #232
Merged
Merged
Conversation
The image node persists a maxWidth (4200 is the default sentinel used by the editor). The headless renderer wrote it straight into an inline max-width:4200px, which overrides any width constraint from CSS, so wide images (and the shared page content around them) overflow and get clipped on narrow viewports such as mobile browsers. Use min(<maxWidth>px, 100%) instead, matching what LazyImage already does in the edit view.
|
👍 @arvinxx Thank you for raising your pull request and contributing to our Community. 非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
|
❤️ Great PR @arvinxx ❤️ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! 项目的成长离不开用户反馈和贡献,感谢您的贡献! |
lobe-tsukumo Bot
pushed a commit
that referenced
this pull request
Oct 18, 2026
### [Version 5.0.2](v5.0.1...v5.0.2) <sup>Released on **2026-10-18**</sup> #### 🐛 Bug Fixes - **misc**: Clamp rendered image max width to the container. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### What's fixed * **misc**: Clamp rendered image max width to the container, closes [#232](#232) ([fbd76b7](fbd76b7)) </details> <div align="right"> [](#readme-top) </div>
|
🎉 This PR is included in version 5.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
分享页 / 只读渲染里,宽图在手机上是按原始宽度铺开并溢出容器被裁掉的(例:https://app.lobehub.com/share/page/pQeCjA1GZcYLbtSt 底部的图表)。
根因
Image 节点会持久化一个
maxWidth,默认值是编辑器里的哨兵值 4200。headless renderer 把它直接写成了内联样式:内联样式优先级高于任何 CSS(包括 lobe-ui Markdown 里的
img { max-width: 100% }),所以图片永远按自身宽度渲染,窄视口下溢出被裁。编辑态的LazyImage其实已经用calc(min(Npx, 100%))处理过,只有渲染器这条路径漏了。修改
src/renderer/renderers/image.tsx的renderImage/renderBlockImage改为:保留持久化宽度(桌面端仍按原尺寸上限渲染),同时不允许超过容器宽度。哨兵值 4200 天然退化成 100%,无需特判。
测试
补充两条回归断言(image / block-image),验证输出为
max-width:min(4200px, 100%)。pnpm vitest run src/renderer/__tests__/LexicalRenderer.test.tsx20 passed。