diff --git a/frontend/app/views/spree/checkout/_delivery.html.erb b/frontend/app/views/spree/checkout/_delivery.html.erb index 3ff0146e173..1cf996ca881 100644 --- a/frontend/app/views/spree/checkout/_delivery.html.erb +++ b/frontend/app/views/spree/checkout/_delivery.html.erb @@ -26,7 +26,9 @@ <% ship_form.object.manifest.each do |item| %> - <%= image_tag item.variant.display_image.attachment(:mini) %> + + <%= render 'spree/shared/image', image: item.variant.display_image, size: :mini %> + <%= item.variant.name %> <%= item.quantity %> <%= display_price(item.variant) %> @@ -72,7 +74,9 @@ <% @differentiator.missing.each do |variant, quantity| %> - <%= image_tag variant.display_image.attachment(:mini) %> + + <%= render 'spree/shared/image', image: variant.display_image, size: :mini %> + <%= variant.name %> <%= quantity %> <%= display_price(variant) %> diff --git a/frontend/app/views/spree/orders/_line_item.html.erb b/frontend/app/views/spree/orders/_line_item.html.erb index 9557feb3bbb..a28c021d76e 100644 --- a/frontend/app/views/spree/orders/_line_item.html.erb +++ b/frontend/app/views/spree/orders/_line_item.html.erb @@ -3,9 +3,9 @@ <% if variant.images.length == 0 %> - <%= link_to image_tag(variant.product.display_image.attachment(:small)), variant.product %> + <%= link_to(render('spree/shared/image', image: variant.product.display_image, size: :small), variant.product) %> <% else %> - <%= link_to image_tag(variant.images.first.attachment.url(:small)), variant.product %> + <%= link_to(render('spree/shared/image', image: variant.images.first, size: :small), variant.product) %> <% end %> diff --git a/frontend/app/views/spree/products/_image.html.erb b/frontend/app/views/spree/products/_image.html.erb index b63b07742be..b1bddec774c 100644 --- a/frontend/app/views/spree/products/_image.html.erb +++ b/frontend/app/views/spree/products/_image.html.erb @@ -1,5 +1,5 @@ <% if defined?(image) && image %> - <%= image_tag image.attachment.url(:product), itemprop: "image" %> + <%= render 'spree/shared/image', image: image, size: :product, itemprop: "image" %> <% else %> - <%= image_tag @product.display_image.attachment(:product), itemprop: "image" %> + <%= render 'spree/shared/image', image: @product.display_image, size: :product, itemprop: "image" %> <% end %> diff --git a/frontend/app/views/spree/shared/_image.html.erb b/frontend/app/views/spree/shared/_image.html.erb new file mode 100644 index 00000000000..6ce66493f74 --- /dev/null +++ b/frontend/app/views/spree/shared/_image.html.erb @@ -0,0 +1,12 @@ +<% size ||= :mini %> +<% itemprop ||= nil %> + +<% if image && image.attachment? %> + <% if itemprop %> + <%= image_tag image.attachment(size), itemprop: itemprop %> + <% else %> + <%= image_tag image.attachment(size) %> + <% end %> +<% else %> + +<% end %> diff --git a/frontend/app/views/spree/shared/_order_details.html.erb b/frontend/app/views/spree/shared/_order_details.html.erb index 454960e9403..0dfa0da8937 100644 --- a/frontend/app/views/spree/shared/_order_details.html.erb +++ b/frontend/app/views/spree/shared/_order_details.html.erb @@ -63,9 +63,9 @@ <% if item.variant.images.length == 0 %> - <%= link_to image_tag(item.variant.product.display_image.attachment(:small)), item.variant.product %> + <%= link_to(render('spree/shared/image', image: item.variant.product.display_image, size: :small), item.variant.product) %> <% else %> - <%= link_to image_tag(item.variant.images.first.attachment.url(:small)), item.variant.product %> + <%= link_to(render('spree/shared/image', image: item.variant.images.first, size: :small), item.variant.product) %> <% end %> diff --git a/frontend/app/views/spree/shared/_products.html.erb b/frontend/app/views/spree/shared/_products.html.erb index ce9a3affb3a..f780e73431c 100644 --- a/frontend/app/views/spree/shared/_products.html.erb +++ b/frontend/app/views/spree/shared/_products.html.erb @@ -28,7 +28,7 @@
  • " data-hook="products_list_item" itemscope itemtype="http://schema.org/Product"> <% cache(@taxon.present? ? [I18n.locale, current_pricing_options, @taxon, product] : [I18n.locale, current_pricing_options, product]) do %>
    - <%= link_to image_tag(product.display_image.attachment(:small), itemprop: "image"), url, itemprop: 'url' %> + <%= link_to(render('spree/shared/image', image: product.display_image, size: :small, itemprop: "image"), url, itemprop: 'url') %>
    <%= link_to truncate(product.name, length: 50), url, class: 'info', itemprop: "name", title: product.name %>