Change timing to get image size

This commit is contained in:
KMY 2023-03-22 22:50:18 +09:00
parent 2eae1bb9bf
commit 2cdaf2af76
2 changed files with 13 additions and 6 deletions

View file

@ -56,6 +56,8 @@ class CustomEmoji < ApplicationRecord
after_commit :remove_entity_cache
after_post_process :set_size
def local?
domain.nil?
end
@ -99,4 +101,15 @@ class CustomEmoji < ApplicationRecord
def downcase_domain
self.domain = domain.downcase unless domain.nil?
end
def set_size
image.queued_for_write.each do |style, file|
if style == :original
image_size = FastImage.size(file.path)
self.image_width = image_size[0]
self.image_height = image_size[1]
return
end
end
end
end