Use direct image URLs for enterprise logos

This commit is contained in:
Matt-Yorkley
2023-06-09 17:48:55 +01:00
parent 5ad37ce6a5
commit 395cf7fb8d

View File

@@ -295,21 +295,15 @@ class Enterprise < ApplicationRecord
end
def logo_url(name)
return unless logo.variable?
url_for(logo.variant(name))
image_url_for(logo, name)
end
def promo_image_url(name)
return unless promo_image.variable?
url_for(promo_image.variant(name))
image_url_for(promo_image, name)
end
def white_label_logo_url(name = :default)
return unless white_label_logo.variable?
url_for(white_label_logo.variant(name))
image_url_for(white_label_logo, name)
end
def website
@@ -461,6 +455,17 @@ class Enterprise < ApplicationRecord
errors.add(:white_label_logo_link, I18n.t(:invalid_url))
end
def image_url_for(image, name)
return unless image.variable?
return image.variant(name).processed.url if image.attachment.service.name == :amazon_public
url_for(image.variant(name))
rescue ActiveStorage::Error => e
Rails.logger.error(e.message)
nil
end
def current_exchange_variants
ExchangeVariant.joins(exchange: :order_cycle)
.merge(Exchange.outgoing)