Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Fix api returning image path

Matthew Kennedy76e358972d6d
diff --git a/api/app/serializers/spree/v2/storefront/cms_section_serializer.rb b/api/app/serializers/spree/v2/storefront/cms_section_serializer.rb
index 69942f5779..5eb672e676 100644
--- a/api/app/serializers/spree/v2/storefront/cms_section_serializer.rb
+++ b/api/app/serializers/spree/v2/storefront/cms_section_serializer.rb
@@ -7,44 +7,44 @@ module Spree
attributes :name, :content, :settings, :link, :fit, :type, :position
attribute :image_one_path do |section|
- if section.image_one_path.attached?
+ if section.image_one.attached?
url_helpers = Rails.application.routes.url_helpers
- url_helpers.rails_representation_path(section.image_one_path, only_path: true)
+ url_helpers.rails_blob_path(section.image_one, only_path: true)
end
end
attribute :image_two_path do |section|
- if section.image_two_path.attached?
+ if section.image_two.attached?
url_helpers = Rails.application.routes.url_helpers
- url_helpers.rails_representation_path(section.image_two_path, only_path: true)
+ url_helpers.rails_blob_path(section.image_two, only_path: true)
end
end
attribute :image_three_path do |section|
- if section.image_three_path.attached?
+ if section.image_three.attached?
url_helpers = Rails.application.routes.url_helpers
- url_helpers.rails_representation_path(section.image_three_path, only_path: true)
+ url_helpers.rails_blob_path(section.image_three, only_path: true)
end
end
attribute :image_four_path do |section|
- if section.image_four_path.attached?
+ if section.image_four.attached?
url_helpers = Rails.application.routes.url_helpers
- url_helpers.rails_representation_path(section.image_four_path, only_path: true)
+ url_helpers.rails_blob_path(section.image_four, only_path: true)
end
end
attribute :image_five_path do |section|
- if section.image_five_path.attached?
+ if section.image_five.attached?
url_helpers = Rails.application.routes.url_helpers
- url_helpers.rails_representation_path(section.image_five_path, only_path: true)
+ url_helpers.rails_blob_path(section.image_five, only_path: true)
end
end
attribute :image_six_path do |section|
- if section.image_six_path.attached?
+ if section.image_six.attached?
url_helpers = Rails.application.routes.url_helpers
- url_helpers.rails_representation_path(section.image_six_path, only_path: true)
+ url_helpers.rails_blob_path(section.image_six, only_path: true)
end
end
diff --git a/frontend/app/views/spree/shared/cms/sections/_side_by_side_promotion.html.erb b/frontend/app/views/spree/shared/cms/sections/_side_by_side_promotion.html.erb
index 69dba47a7d..95edb26ef2 100644
--- a/frontend/app/views/spree/shared/cms/sections/_side_by_side_promotion.html.erb
+++ b/frontend/app/views/spree/shared/cms/sections/_side_by_side_promotion.html.erb
@@ -21,7 +21,7 @@
class: 'd-flex align-items-end justify-content-center bg-light text-center overflow-hidden homepage-bottom-box',
style: '--aspect-ratio:54/35;' do %>
- <% if section.image_one.present? %>
+ <% if section.image_one.attached? %>
<!-- XS to MD -->
<img class="d-md-none lazyload"
data-src="<%= main_app.url_for(section.image_one.attachment.variant(resize: '387x250>')) %>"