Add tootctl command for set custom emoji size if not set
This commit is contained in:
parent
2cdaf2af76
commit
a319dbb7d5
2 changed files with 28 additions and 6 deletions
|
@ -56,7 +56,7 @@ class CustomEmoji < ApplicationRecord
|
|||
|
||||
after_commit :remove_entity_cache
|
||||
|
||||
after_post_process :set_size
|
||||
after_post_process :set_post_size
|
||||
|
||||
def local?
|
||||
domain.nil?
|
||||
|
@ -76,6 +76,10 @@ class CustomEmoji < ApplicationRecord
|
|||
shortcode
|
||||
end
|
||||
|
||||
def update_size
|
||||
set_size(image)
|
||||
end
|
||||
|
||||
class << self
|
||||
def from_text(text, domain = nil)
|
||||
return [] if text.blank?
|
||||
|
@ -102,14 +106,17 @@ class CustomEmoji < ApplicationRecord
|
|||
self.domain = domain.downcase unless domain.nil?
|
||||
end
|
||||
|
||||
def set_size
|
||||
def set_post_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
|
||||
set_size(file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def set_size(file)
|
||||
image_size = FastImage.size(file.path)
|
||||
self.image_width = image_size[0]
|
||||
self.image_height = image_size[1]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue