Skip to content

feat: auto-fit images (center-crop + downscale) in MediaUploader instead of rejecting#14

Merged
KruGoL merged 1 commit into
mainfrom
feat/mediauploader-auto-fit
Jun 19, 2026
Merged

feat: auto-fit images (center-crop + downscale) in MediaUploader instead of rejecting#14
KruGoL merged 1 commit into
mainfrom
feat/mediauploader-auto-fit

Conversation

@KruGoL

@KruGoL KruGoL commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

When an image missed a kind's aspect ratio or exceeded its max dimensions,
MediaUploader rejected it ("Wrong aspect ratio" / "Image too large"). Now it
auto-fits: center-crop to the kind's aspectRatio and downscale to
maxWidth/maxHeight via canvas, then upload the corrected image (the preview shows
the result).

No-op for SVG and when canvas / createImageBitmap is unavailable (older browsers,
jsdom) — there the existing dimension check stays as the fallback so the server is
not 422'd. Because this lives in the shared MediaUploader, every consumer
(dev-portal, backoffice) gets it. An interactive cropper for logo/banner is a
planned follow-up.

…ead of rejecting

When an image missed a kind's aspect ratio or exceeded its max dimensions,
MediaUploader rejected it ("Wrong aspect ratio" / "Image too large"). Now it
auto-fits: center-crop to the kind's aspectRatio and downscale to
maxWidth/maxHeight via canvas, then upload the corrected image (the preview shows
the result).

No-op for SVG and when canvas / createImageBitmap is unavailable (older browsers,
jsdom) — there the existing dimension check stays as the fallback so the server is
not 422'd. Because this lives in the shared MediaUploader, every consumer
(dev-portal, backoffice) gets it. An interactive cropper for logo/banner is a
planned follow-up.
@KruGoL KruGoL merged commit caf69f4 into main Jun 19, 2026
@KruGoL KruGoL deleted the feat/mediauploader-auto-fit branch June 19, 2026 18:31
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