Skip to content

Related-project thumbnail on project page clips the crop (aspect mismatch, 160×90 vs 5:3) #1416

Description

@jonfroehlich

Problem

On the project page, the "related projects" thumbnails render at 160×90 (16:9) while Project.cropping is an ImageRatioField locked to 5:3 (PROJECT_THUMBNAIL_SIZE = 500×300). Because the render aspect ratio differs from the crop-box aspect ratio, easy_thumbnails applies a second center-crop on top of the editor's crop box — silently trimming the top/bottom of the chosen crop (same bug class we just fixed for the news detail image).

Source: website/templates/website/project.html:554

{% thumbnail related_project.gallery_image '160x90' box=related_project.cropping crop=True upscale=True %}

Why it matters

The admin crop preview (5:3) is not what ships in this thumbnail — editors can't predict the extra crop. Low severity (small thumbnail), but it's the identical WYSIWYG-breaking defect.

Fix

Render at the crop aspect ratio; only vary pixel size. 160×90160×96 (5:3). No model change, no re-cropping needed.

Guard

website/tests/test_news_crop_aspect.py (added in the news fix, v2.26.1) enforces this invariant for news renders. Consider generalizing it to project renders too when fixing this.

Invariant

Any {% thumbnail X box=Y.cropping ... crop %} must use Y's crop aspect ratio; only the pixel size may vary. Otherwise easy_thumbnails re-crops.

Context: found while fixing the news-image head-clipping bug (branch news-crop-aspect-mismatch, v2.26.1).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions