mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
DEV: Improve script/downsize_uploads.rb
(#13508)
* Only shrink images that are used in Posts and no other models * Don't save the upload if the size is the same
This commit is contained in:
@ -35,7 +35,11 @@ def process_uploads
|
||||
dimensions_count = 0
|
||||
downsized_count = 0
|
||||
|
||||
scope = Upload.by_users.where("LOWER(extension) IN ('jpg', 'jpeg', 'gif', 'png')")
|
||||
scope = Upload
|
||||
.by_users
|
||||
.with_no_non_post_relations
|
||||
.where("LOWER(extension) IN ('jpg', 'jpeg', 'gif', 'png')")
|
||||
|
||||
scope = scope.where(<<-SQL, MAX_IMAGE_PIXELS)
|
||||
COALESCE(width, 0) = 0 OR
|
||||
COALESCE(height, 0) = 0 OR
|
||||
|
Reference in New Issue
Block a user