Skip to content

Getting image assets links using the API #4383

Discussion options

You must be logged in to vote

Starting from Solidus 3.1 (#4039), we can configure the JSON response attributes of API's endpoints (including the ones related to taxons) with a standard preference.

In your config/initializers/spree.rb, you can add the following:

Spree::Api::Config.configure do |config|
  config.taxon_attributes += [ :api_icon_url ]
end

And defining a new method on the taxon to retrieve the right size of the icon that you want to use:

# app/overrides/your_store_name/spree/taxon/add_api_icon_url

module YourStoreName
  module Spree
    module Taxon
      module AddApuIconUrl
        def api_icon_url
          icon.url(:small) # :or :original
        end

        ::Spree::Taxon.prepend self
      end
    end

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
6 replies
@kennyadsl
Comment options

@morismael
Comment options

@Azeem838
Comment options

@elia
Comment options

@morismael
Comment options

Answer selected by morismael
Comment options

You must be logged in to vote
2 replies
@kennyadsl
Comment options

@morismael
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants