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.

Add support for Cloudinary CDN (#11615)

Damian Legawiecad277a6c6e56
diff --git a/core/config/routes.rb b/core/config/routes.rb
index 88881a63b9..cdc79a307b 100644
--- a/core/config/routes.rb
+++ b/core/config/routes.rb
@@ -2,7 +2,17 @@
# see: https://github.com/rails/rails/issues/34872
Rails.application.routes.draw do
direct :cdn_image do |model, options|
- if model.respond_to?(:signed_id)
+ if model.blob.service_name == 'cloudinary' && defined?(Cloudinary)
+ if model.class.method_defined?(:has_mvariation)
+ Cloudinary::Utils.cloudinary_url(model.blob.key,
+ width: model.variation.transformations[:resize_to_limit].first,
+ height: model.variation.transformations[:resize_to_limit].last,
+ crop: :fill
+ )
+ else
+ Cloudinary::Utils.cloudinary_url(model.blob.key)
+ end
+ elsif model.respond_to?(:signed_id)
route_for(
:rails_service_blob_proxy,
model.signed_id,