Skip to content

feat: validate image pixel dimensions in MediaUploader#11

Merged
KruGoL merged 1 commit into
mainfrom
feat/mediauploader-dimension-validation
Jun 19, 2026
Merged

feat: validate image pixel dimensions in MediaUploader#11
KruGoL merged 1 commit into
mainfrom
feat/mediauploader-dimension-validation

Conversation

@KruGoL

@KruGoL KruGoL commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

MediaUploader.handleFile only checked mime + byte-size, so an oversized image
passed the input and failed only on the server confirm with a 422
(DIMENSIONS_EXCEEDED) after the S3 PUT. Add a client-side pixel-dimension +
aspect-ratio check via createImageBitmap, validated against the kind's
MEDIA_LIMITS (maxWidth/maxHeight, aspectRatio +/- aspectTolerance), so oversized
images are rejected at the input with a clear message.

SVG is skipped (no raster dimensions). Decode failures and environments without
createImageBitmap (e.g. jsdom) fail open and return null, so the server stays the
real enforcement. Because MediaGallery wraps the same MediaUploader, this covers
logo, banner, screenshot, image and background in every consumer. Adds a test.

MediaUploader.handleFile only checked mime + byte-size, so an oversized image
passed the input and failed only on the server confirm with a 422
(DIMENSIONS_EXCEEDED) after the S3 PUT. Add a client-side pixel-dimension +
aspect-ratio check via createImageBitmap, validated against the kind's
MEDIA_LIMITS (maxWidth/maxHeight, aspectRatio +/- aspectTolerance), so oversized
images are rejected at the input with a clear message.

SVG is skipped (no raster dimensions). Decode failures and environments without
createImageBitmap (e.g. jsdom) fail open and return null, so the server stays the
real enforcement. Because MediaGallery wraps the same MediaUploader, this covers
logo, banner, screenshot, image and background in every consumer. Adds a test.
@KruGoL KruGoL merged commit a2aea12 into main Jun 19, 2026
@KruGoL KruGoL deleted the feat/mediauploader-dimension-validation branch June 19, 2026 17:27
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