mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add product thumbnais to serializer for cart dropdown images
This commit is contained in:
@@ -3,7 +3,7 @@ class Api::VariantSerializer < ActiveModel::Serializer
|
||||
:options_text, :unit_value, :unit_description, :unit_to_display,
|
||||
:display_as, :display_name, :name_to_display,
|
||||
:price, :on_demand, :on_hand, :fees, :price_with_fees,
|
||||
:tag_list
|
||||
:tag_list, :thumb_url
|
||||
|
||||
delegate :price, to: :object
|
||||
|
||||
@@ -30,4 +30,12 @@ class Api::VariantSerializer < ActiveModel::Serializer
|
||||
|
||||
object.tag_list
|
||||
end
|
||||
|
||||
def thumb_url
|
||||
if object.images.present?
|
||||
object.images.first.attachment.url(:mini)
|
||||
else
|
||||
"/assets/noimage/mini.png"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user