Limit Image Uploads
Guard the Image tool against oversized or huge uploads with config.image.
Cap the file size and the maximum dimension so users can't drop in a 50 MP photo.
When to use this
- You're uploading results to a backend with size limits.
- You want predictable performance regardless of input.
- You need to reject obviously-wrong files early, with a clear message.
Configure the limits
<ImageEditor
src="/photo.jpg"
config={{
image: {
maxFileSize: 5 * 1024 * 1024, // 5 MB
maxDimension: 4096, // px, longest edge
},
}}
/>
maxFileSize(bytes) rejects files larger than the limit with an inline error.maxDimension(px) downscales images whose longest edge exceeds the limit.
Omit image to use the built-in defaults.
Try it
Open the Image tool and add a file — oversized uploads are rejected inline:
Image Editor
Loading...
Loading image...Next steps
- Configure the Shapes Tool — curate the shape set.
- Save & Restore Scenes — serialize the full editor state.
- Configuration — the full config reference.
Verified by
tests/guides/image-upload-limits.spec.tsxin the@editx/image-editorpackage.