mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
Getting images working
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
module Spree
|
||||
|
||||
class ImageSerializer < ActiveModel::Serializer
|
||||
attributes :id, :mini_url, :alt
|
||||
attributes :id, :small_url, :alt
|
||||
|
||||
def small_url
|
||||
object.attachment.url(:small, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
%tbody{"ng-repeat" => "product in data.products "}
|
||||
%tr.product
|
||||
%td
|
||||
-#{{ product.master.images[0].mini_url }}
|
||||
%img{src: "{{ product.master.images[0].small_url }}"}
|
||||
-#{{product.master.images[0].alt}}
|
||||
%td
|
||||
%h5
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
%shop{"ng-app" => "Shop"}
|
||||
%navigation
|
||||
%distributor.details.row
|
||||
%img.left{src: ""}
|
||||
-#%img.left{src: @distributor.}
|
||||
%h4
|
||||
= @distributor.name
|
||||
%location= @distributor.address.city
|
||||
|
||||
9
spec/serializers/spree/image_serializer_spec.rb
Normal file
9
spec/serializers/spree/image_serializer_spec.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Spree::ImageSerializer do
|
||||
it "should give us the small url" do
|
||||
image = Spree::Image.new(attachment: double(:attachment))
|
||||
image.attachment.should_receive(:url).with(:small, false)
|
||||
Spree::ImageSerializer.new(image).to_json
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user