Skip to content

fix: 修复文章封面图被强制裁切#376

Merged
CuteLeaf merged 1 commit into
CuteLeaf:masterfrom
SugarMGP:fix-coverimage
May 31, 2026
Merged

fix: 修复文章封面图被强制裁切#376
CuteLeaf merged 1 commit into
CuteLeaf:masterfrom
SugarMGP:fix-coverimage

Conversation

@SugarMGP
Copy link
Copy Markdown
Contributor

Type of change

  • Bug fix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other (please describe):

Checklist

  • I have read the CONTRIBUTING document.
  • I have checked to ensure that this Pull Request is not for personal changes.
  • I have performed a self-review of my own code.
  • My changes generate no new warnings.

Related Issue

No related issue.

Changes

修复了封面图片被强制裁切到固定 1200×800 比例的问题。

新增 getPictureSizeProps 函数,根据图片实际宽高比动态计算输出尺寸:

  • 预览模式:固定 400×300
  • 非预览模式:宽度固定 1200,高度按原图比例计算(Math.round(1200 / (width / height)))

How To Test

  1. 使用不同宽高比的封面图片(如 16:9、4:3、1:1)发布文章
  2. 检查首页卡片和文章详情页的封面图是否保持原始比例,未被拉伸或裁切变形

Screenshots (if applicable)

修复前:

image

修复后:

image

Additional Notes

@netlify
Copy link
Copy Markdown

netlify Bot commented May 31, 2026

Deploy Preview for demo-firefly ready!

Name Link
🔨 Latest commit 94890d8
🔍 Latest deploy log https://app.netlify.com/projects/demo-firefly/deploys/6a1c25742ac0b3000913f3c2
😎 Deploy Preview https://deploy-preview-376--demo-firefly.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@CuteLeaf CuteLeaf merged commit fead4c3 into CuteLeaf:master May 31, 2026
9 checks passed
@CuteLeaf
Copy link
Copy Markdown
Owner

感谢PR 已合并

@SugarMGP SugarMGP deleted the fix-coverimage branch May 31, 2026 12:45
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