<% eventable.attachments.each do |attachment| %>
- <% size = [800, 600] %>
+ <% variant = Attachments::VARIANTS[:small] %>
<% width = attachment.metadata["width"] %>
<% height = attachment.metadata["height"] %>
<% if attachment.previewable? %>
- <%= image_tag url_for(attachment.preview(resize_to_limit: size)), class: "attachment attachment--image", width: width, height: height %>
+ <%= image_tag url_for(attachment.preview(variant)), class: "attachment attachment--image", width: width, height: height %>
<% elsif attachment.variable? %>
- <%= image_tag url_for(attachment.variant(resize_to_limit: size)), class: "attachment attachment--image", width: width, height: height %>
+ <%= image_tag url_for(attachment.variant(variant)), class: "attachment attachment--image", width: width, height: height %>
<% else %>
<%= attachment.filename.extension&.downcase.presence || "unknown" %>
@@ -16,4 +16,4 @@
<% end %>
<% end %>
-<% end %>
\ No newline at end of file
+<% end %>
diff --git a/config/initializers/action_text.rb b/config/initializers/action_text.rb
new file mode 100644
index 000000000..b2724b1c7
--- /dev/null
+++ b/config/initializers/action_text.rb
@@ -0,0 +1,20 @@
+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.merge(preprocessed: true)
+ end
+ end
+ end
+ end
+ end
+end
+
+ActiveSupport.on_load(:action_text_rich_text) do
+ include ActionText::Extensions::RichText
+end