From d19a67ee49b1d58ba65e2bd347ccf363bba702dd Mon Sep 17 00:00:00 2001 From: eastagiletracker <310448263+eastagiletracker@users.noreply.github.com> Date: Wed, 12 Aug 2026 12:36:43 +0700 Subject: [PATCH] Render related-project thumbnails at the crop ratio The related-projects sidebar rendered gallery_image at 160x90 (16:9) while Project.cropping is locked to a 5:3 crop box (PROJECT_THUMBNAIL_SIZE 500x300). crop_corners applies the editor's box and scale_and_crop then center-crops it a second time to reach 16:9, silently trimming 6.25% of the height the editor framed. The admin preview only ever shows the 5:3 box, so the trim was invisible to editors -- the same defect the news detail render hit at 750x350. Render at 160x96 (5:3) instead: same width, no model change and no re-cropping of existing content. .project-sidebar-related-thumbnail is width:80px with height:auto, so the thumbnail is 3 CSS pixels taller and nothing else moves. Generalize test_news_crop_aspect.py into test_crop_aspect.py so the invariant covers every crop field rather than only news. Renders are matched by their box= expression and each expression maps to the ImageRatioField that defines its ratio, so the test reads the ratio off the model instead of hardcoding it. A crop box the test doesn't know about now fails instead of being skipped, which surfaced the previously unchecked member.person.easter_egg_crop (245x245 against a 245x245 crop -- correct, just uncovered). CropProcessorTests pins the pixel-level behavior through the real crop_corners -> scale_and_crop chain. --- website/templates/website/news_item.html | 2 +- website/templates/website/project.html | 2 +- website/tests/test_crop_aspect.py | 243 +++++++++++++++++++++++ website/tests/test_news_crop_aspect.py | 134 ------------- 4 files changed, 245 insertions(+), 136 deletions(-) create mode 100644 website/tests/test_crop_aspect.py delete mode 100644 website/tests/test_news_crop_aspect.py diff --git a/website/templates/website/news_item.html b/website/templates/website/news_item.html index 81e540da..7a09ee1d 100644 --- a/website/templates/website/news_item.html +++ b/website/templates/website/news_item.html @@ -125,7 +125,7 @@

{{ news_item.title }}

If it doesn't, easy_thumbnails applies a second center-crop on top of the editor's crop box, silently trimming the top/bottom of the chosen crop (e.g. clipping people's heads). 750x450 == 5:3, so the rendered image is - exactly what the admin crop preview shows. See test_news_crop_aspect.py. + exactly what the admin crop preview shows. See test_crop_aspect.py. {% endcomment %} Related Projects class="project-sidebar-related-thumbnail-link" aria-label="View project: {{ related_project.name }}"> {{ related_project.get_thumbnail_alt_text }}