Skip to content

fix: accept vehicle images of any size and aspect ratio - #4

Merged
DGINXREAL merged 2 commits into
mainfrom
fix/vehicle-image-upload
Aug 5, 2026
Merged

fix: accept vehicle images of any size and aspect ratio#4
DGINXREAL merged 2 commits into
mainfrom
fix/vehicle-image-upload

Conversation

@theRomanOak

Copy link
Copy Markdown
Collaborator

Problem

Two separate causes in the image field of VehicleForm, both hit as soon as an image is not exactly 4:3 or is smaller than 2000 pixels.

1. The aspect ratio was enforced on the server. imageAspectRatio('4:3') is not only a hint for the browser crop editor — it also produces Rule::dimensions()->ratio(4/3) via BaseFileUpload::getRules(). Any image in a different ratio was rejected outright:

Component has errors: "data.image_path" =>
["The fahrzeugbild field has invalid image dimensions."]

2. Small images were scaled up. automaticallyResizeImagesToWidth('2000') ran with Filament's default shouldAutomaticallyUpscaleImagesWhenResizing = true, so an 800 pixel image was blown up to 2000 — visibly soft, and several times the original file size.

Change

  • imageAspectRatio('4:3') and automaticallyOpenImageEditorForAspectRatio() removed, along with the now-dead dimensions validation message. The crop editor stays available, it is just no longer mandatory.
  • automaticallyUpscaleImagesWhenResizing(false) added.
  • Resize mode covercontain. Without a fixed aspect ratio and with no target height set, cover would crop a panorama to a square; contain only ever scales down.
  • maxSize(10 MB) untouched — it is now the only constraint on an image.

Display needed no change: Filament already applies object-cover to both table image columns and infolist images (tables/resources/css/columns/image.css:5, infolists/resources/css/components/image.css:5), so mixed aspect ratios do not make rows or cards uneven.

Verification

Full suite: 388 passed (1241 assertions). Pint clean.

New VehicleImageUploadTest covers: an off-ratio image is accepted, a small image is accepted, a non-image is rejected, and an image above 10 MB is still rejected.

One half of this cannot be proven server-side. The upscaling happens in the browser, inside FilePondPluginImageResize, which a fillForm() test never runs. What the suite does assert is that the instruction reaches the component (shouldAutomaticallyUpscaleImagesWhenResizing() === false, mode contain), so a later edit cannot drop it silently. The actual pixel result should be confirmed once by hand: upload an 800×600 image and check the stored file is still 800×600.

The existing test that asserted the 4:3 rejection was testing the reported bug as if it were a feature; it now asserts that a square image is accepted.

🤖 Generated with Claude Code

theRomanOak and others added 2 commits August 5, 2026 07:39
Two separate causes, both in the image field of VehicleForm.

imageAspectRatio('4:3') was not only a hint for the browser crop editor.
It also produces a server-side Rule::dimensions()->ratio(4/3) via
BaseFileUpload::getRules(), so any image in a different ratio was rejected
outright — reproduced by the first test in VehicleImageUploadTest:

    Component has errors: "data.image_path" =>
    ["The fahrzeugbild field has invalid image dimensions."]

automaticallyResizeImagesToWidth('2000') ran with Filament's default
shouldAutomaticallyUpscaleImagesWhenResizing = true, so an 800 pixel image
was scaled *up* to 2000 — visibly soft and several times the original file
size. That half happens in the browser (FilePondPluginImageResize) and is
not observable from a server-side test; it is verified by uploading and
reading back the stored dimensions.

The resize mode moves from 'cover' to 'contain': without a fixed aspect
ratio and with no target height set, 'cover' would crop a panorama to a
square. 'contain' only ever scales down.

The crop editor stays available, it is just no longer mandatory. The 10 MB
limit is untouched — it is now the only constraint on an image.

Display needs no change: Filament already applies object-cover to both
table image columns and infolist images (tables/resources/css/columns/
image.css, infolists/resources/css/components/image.css), so mixed aspect
ratios do not make rows or cards uneven.

The existing test asserting the 4:3 rejection tested the reported bug as if
it were a feature; it now asserts that a square image is accepted.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The upscaling half of the bug happens in the browser, inside
FilePondPluginImageResize, so no server-side test can observe the result.
This asserts the instruction to not upscale actually reaches the component,
so a later edit cannot drop it silently.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@DGINXREAL
DGINXREAL merged commit e547a35 into main Aug 5, 2026
3 checks passed
@DGINXREAL
DGINXREAL deleted the fix/vehicle-image-upload branch August 5, 2026 07:46
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