mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-17 04:34:24 +00:00
Use direct image URLs for enterprise logos
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user