21f3f72647
Process variants synchronously on attachment to close the window between image upload and variant availability, guaranteeing that we won't have lazy variant processing attempts in GET requests. Tradeoff is that we do variant processing in upload requests, which is actually desirable. We're working with images that should take milliseconds to resize given that we'll already have the file on hand. References https://github.com/rails/rails/pull/51951
21 lines
532 B
Ruby
21 lines
532 B
Ruby
module ActionText
|
|
module Extensions
|
|
module RichText
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
# This overrides the default :embeds association!
|
|
has_many_attached :embeds do |attachable|
|
|
::Attachments::VARIANTS.each do |variant_name, variant_options|
|
|
attachable.variant variant_name, **variant_options, process: :immediately
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
ActiveSupport.on_load(:action_text_rich_text) do
|
|
include ActionText::Extensions::RichText
|
|
end
|