Skip to content

Instantly share code, notes, and snippets.

@prsanjay
Created June 30, 2019 06:01
Show Gist options
  • Select an option

  • Save prsanjay/ea33f9cc1e67f3e74998f00a07ae2b8f to your computer and use it in GitHub Desktop.

Select an option

Save prsanjay/ea33f9cc1e67f3e74998f00a07ae2b8f to your computer and use it in GitHub Desktop.

Revisions

  1. prsanjay created this gist Jun 30, 2019.
    18 changes: 18 additions & 0 deletions taxon_header_image.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    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