Skip to content

Fix news detail crop aspect mismatch (clipped heads) + guard test#1424

Merged
jonfroehlich merged 1 commit into
masterfrom
news-crop-aspect-mismatch
Jul 23, 2026
Merged

Fix news detail crop aspect mismatch (clipped heads) + guard test#1424
jonfroehlich merged 1 commit into
masterfrom
news-crop-aspect-mismatch

Conversation

@jonfroehlich

Copy link
Copy Markdown
Member

What & why

The news detail page rendered the featured image at 750x350 (15:7) while NewsItem.cropping is locked to a 5:3 crop box (NEWS_THUMBNAIL_SIZE 500x300). easy_thumbnails applied the editor's 5:3 box and then a second center-crop to force 15:7 — silently trimming the top/bottom of the chosen crop and clipping people's heads. The admin Cropper.js preview only ever shows the 5:3 box, so the bug was invisible to editors.

Reported 2026-07-01 (McDevitt civics photo). This has been live on prod the whole time — the fix was written weeks ago but never actually committed (it was sitting as uncommitted changes in a worktree; discovered during branch cleanup).

Fix

  • news_item.html: detail render 750x350750x450 (5:3), so the published image exactly matches the admin crop preview (WYSIWYG). No model change, no re-cropping — all existing crops become correct immediately. Kept 5:3 (not 16:9, which is wider and would clip people-photos more).
  • test_news_crop_aspect.py: scans templates and fails if any crop-enabled on-page news render uses a size whose aspect ratio differs from the crop editor's. OG social card (1200x630) and the round 50x50 sidebar chip are documented, intentional exceptions.

Known latent (out of scope, documented in the test)

project.html related-project thumb renders 160x90 (16:9) against a 5:3 Project crop — same class of bug, left for a future project-page pass.

Testing

  • python manage.py test website.tests.test_news_crop_aspect --settings=makeabilitylab.settings_test2 passed (ran in a one-off container against this branch).

Note

Version bump intentionally not included — the original draft (2.26.1) is behind current master (2.27.2). Needs a fresh bump before/at merge.

🤖 Generated with Claude Code

The news detail page rendered the featured image at 750x350 (15:7) while
NewsItem.cropping is locked to a 5:3 crop box (NEWS_THUMBNAIL_SIZE 500x300).
easy_thumbnails applied the editor's 5:3 box and THEN a second center-crop to
force 15:7, silently trimming the top/bottom of the chosen crop -- clipping
people's heads. The admin preview only ever shows the 5:3 box, so the bug was
invisible to editors.

Render at 750x450 (5:3) so the published image exactly matches the admin crop
preview (WYSIWYG). Add test_news_crop_aspect.py, which scans the templates and
fails if any crop-enabled on-page news render uses a size whose aspect ratio
doesn't match the crop editor's; the OG social card (1200x630) and round 50x50
sidebar chip are documented, intentional exceptions.

Version bump deferred (2.26.1 draft was behind current master 2.27.2).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jonfroehlich
jonfroehlich merged commit 70c5e2b into master Jul 23, 2026
3 checks passed
jonfroehlich added a commit that referenced this pull request Jul 23, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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