Created
June 30, 2019 06:01
-
-
Save prsanjay/ea33f9cc1e67f3e74998f00a07ae2b8f to your computer and use it in GitHub Desktop.
Add new attachment to taxons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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