-
First, configure Shrine. I'll leave this exercise to the reader as it's very dependent on how you'll be storing your files (on a server, on S3, etc.)
-
Define an alternate attachment module (instead of the ActiveStorage or Paperclip one):
module ShrineImageAttachment extend ActiveSupport::Concern included do # FIXME: Use whatever store you have defined that you want to use for product images. To avoid caching issues, I recommend using some kind of public store. include Shrine::Attachment(:attachment, store: :public_images) end class_methods do def attachment_definitions # FIXME: This is required by (if I remember correctly) the API templates. It should be updated to actually reflect the available styles. {attachment: {styles: {}}} end end def url(style = default_style) # FIXME: Currently this just returns the same URL for the attachment every time, regardless of what "style" (like "thumbnail") is requested. attachment_url || "noimage/#{style}.png" end end
-
Configure Solidus to use the attachment module. In your initializer where you configure Solidus, add
config.image_attachment_module = "ShrineImageAttachment"
. You may also want to setconfig.taxon_attachment_module
.
Created
December 5, 2021 21:11
-
-
Save jarednorman/8baa00ef95f6d9c8c85aec015ada9442 to your computer and use it in GitHub Desktop.
Using Shrine with Solidus
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment