FEATURE: automatically downsize large images#10
Conversation
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| dim = dimensions(width, height) | ||
| def self.downsize(from, to, dimensions, opts={}) | ||
| optimize("downsize", from, to, dimensions, opts) | ||
| end |
There was a problem hiding this comment.
Duplicate downsize method breaks existing emoji resize callers
High Severity
Two def self.downsize methods are defined on OptimizedImage. In Ruby, the second definition (3 args: from, to, dimensions, opts={}) silently replaces the first (4 args: from, to, max_width, max_height, opts={}). The existing caller in ResizeEmoji passes 5 arguments (path, path, 100, 100, opts), which will raise an ArgumentError at runtime since the surviving method only accepts 3–4 arguments.
Additional Locations (1)
| // check file size | ||
| var fileSizeKB = file.size / 1024; | ||
| var maxSizeKB = Discourse.SiteSettings['max_' + type + '_size_kb']; | ||
| var maxSizeKB = 10 * 1024; // 10MB |
There was a problem hiding this comment.
Hardcoded upload limit ignores per-type site settings
Medium Severity
The client-side file size validation replaces the dynamic Discourse.SiteSettings['max_' + type + '_size_kb'] lookup with a hardcoded 10 * 1024 (10 MB) for all upload types. This removes the distinction between image and attachment limits, and ignores admin-configured size settings. Non-image attachments that pass client validation at 10 MB will still be rejected server-side if the configured max_attachment_size_kb is smaller, leading to confusing error behavior.


Test 1
Summary by CodeRabbit
New Features
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.
Replicated from ai-code-review-evaluation/discourse-coderabbit#1
Note
Medium Risk
Touches upload validation and image processing paths; downsizing loops and the new 10MB hardcoded limits could change upload behavior and resource usage in production.
Overview
Enables oversized image uploads to be accepted by automatically downsizing them server-side until they fit within
SiteSetting.max_image_size_kb(up to 5 attempts), instead of failing immediately.Standardizes upload size handling by hardcoding a 10MB limit in the client-side validation/error messaging and in API URL-download handling, and refactors
OptimizedImageresize/downsize helpers to pass dimensions as a single string tooptimize.Written by Cursor Bugbot for commit ffbaf8c. Configure here.