mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 10:53:58 +08:00
43e52a7dc1
Dependency on gifsicle, allow_animated_avatars and allow_animated_thumbnails site settings were all removed. Animated GIF images are still allowed, but the generated optimized images are no longer animated for those (which were used for avatars and thumbnails). The added 'animated' is populated by extracting information using FastImage. This field was used to selectively reoptimize old animations. This process happens in the background.
24 lines
597 B
Ruby
24 lines
597 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class UpdateAnimatedUploads < ::Jobs::Scheduled
|
|
every 1.hour
|
|
|
|
MAX_PROCESSED_GIF_IMAGES ||= 200
|
|
|
|
def execute(args)
|
|
Upload
|
|
.where("extension = 'gif' OR (extension IS NULL AND original_filename LIKE '%.gif')")
|
|
.where(animated: nil)
|
|
.limit(MAX_PROCESSED_GIF_IMAGES)
|
|
.each do |upload|
|
|
uri = Discourse.store.path_for(upload) || upload.url
|
|
upload.update!(animated: FastImage.animated?(uri))
|
|
upload.optimized_images.destroy_all if upload.animated
|
|
end
|
|
|
|
nil
|
|
end
|
|
end
|
|
end
|