FEATURE: automatically downsize large images#10
Conversation
|
|
||
| def self.optimize(operation, from, to, width, height, opts={}) | ||
| dim = dimensions(width, height) | ||
| def self.downsize(from, to, dimensions, opts={}) |
There was a problem hiding this comment.
Defining def self.downsize(from, to, dimensions, opts={}) here overrides the earlier downsize(from, to, max_width, max_height, opts={}) (Ruby uses the last definition), changing arity and causing ArgumentError at existing call sites that pass width/height (e.g., Jobs::ResizeEmoji).
🤖 Was this useful? React with 👍 or 👎
| if tempfile && tempfile.size > 0 && SiteSetting.max_image_size_kb > 0 && FileHelper.is_image?(filename) | ||
| attempt = 5 | ||
| while attempt > 0 && tempfile.size > SiteSetting.max_image_size_kb.kilobytes | ||
| OptimizedImage.downsize(tempfile.path, tempfile.path, "80%", allow_animation: SiteSetting.allow_animated_thumbnails) |
There was a problem hiding this comment.
Passing a percentage string ("80%") to OptimizedImage.downsize will propagate to the animated path (gifsicle --resize-fit #{dimensions}), which typically expects WxH, so GIF downsizing can fail when allow_animation is true. This can leave large GIFs unshrunk and still over the site limit after the loop (also applies to other locations in the PR).
🤖 Was this useful? React with 👍 or 👎
No description provided.