Skip to content

Instantly share code, notes, and snippets.

@prsanjay
Created June 30, 2019 06:01
Show Gist options
  • Save prsanjay/ea33f9cc1e67f3e74998f00a07ae2b8f to your computer and use it in GitHub Desktop.
Save prsanjay/ea33f9cc1e67f3e74998f00a07ae2b8f to your computer and use it in GitHub Desktop.
Add new attachment to taxons
module Spree
class TaxonHeaderImage < Asset
include Rails.application.config.use_paperclip ? Configuration::Paperclip : Configuration::ActiveStorage
include Rails.application.routes.url_helpers
def styles
self.class.styles.map do |_, size|
width, height = size[/(\d+)x(\d+)/].split('x')
{
url: polymorphic_path(attachment.variant(resize: size), only_path: true),
width: width,
height: height
}
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment