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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Use CDN for product images, logos and favicons
Damian Legawiec107040cd15e5
diff --git a/core/app/helpers/spree/base_helper.rb b/core/app/helpers/spree/base_helper.rbindex 9272c741b0..1c1ef7a8c9 100644--- a/core/app/helpers/spree/base_helper.rb+++ b/core/app/helpers/spree/base_helper.rb@@ -61,9 +61,9 @@ module SpreeDEPRECATIONimage_path ||= if current_store.logo.attached? && current_store.logo.variable?- main_app.url_for(current_store.logo.variant(resize_to_limit: [244, 104]))+ main_app.cdn_image_url(current_store.logo.variant(resize_to_limit: [244, 104]))elsif current_store.logo.attached? && current_store.logo.image?- main_app.url_for(current_store.logo)+ main_app.cdn_image_url(current_store.logo)else'logo/spree_50.png'end@@ -76,7 +76,7 @@ module Spreeenddef spree_favicon_path- main_app.url_for(current_store.favicon || 'favicon.ico')+ main_app.cdn_image_url(current_store.favicon || 'favicon.ico')enddef object@@ -88,7 +88,7 @@ module Spreeif object.is_a? Spree::Productimage = default_image_for_product_or_variant(object)- og_meta['og:image'] = main_app.url_for(image.attachment) if image&.attachment+ og_meta['og:image'] = main_app.cdn_image_url(image.attachment) if image&.attachmentog_meta['og:url'] = spree.url_for(object) if frontend_available? # url_for product neededog_meta['og:type'] = object.class.name.demodulize.downcase@@ -238,7 +238,7 @@ module Spreedef create_product_image_tag(image, product, options, style)options[:alt] = image.alt.blank? ? product.name : image.alt- image_tag main_app.url_for(image.url(style)), options+ image_tag main_app.cdn_image_url(image.url(style)), optionsenddef define_image_method(style)@@ -249,7 +249,7 @@ module Spreeimg = if image_path.present?create_product_image_tag image_path, product, options, styleelse- inline_svg_tag "noimage/backend-missing-image.svg", class: "noimage", size: "60%*60%"+ inline_svg_tag 'noimage/backend-missing-image.svg', class: 'noimage', size: '60%*60%'endcontent_tag(:div, img, class: "admin-product-image-container #{style}-img")