mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-04 02:31:33 +00:00
Move reformat_styles to initializer, it's the only place where it is used
This commit is contained in:
@@ -18,6 +18,25 @@ Spree::Gateway.class_eval do
|
||||
acts_as_taggable
|
||||
end
|
||||
|
||||
# Spree stores attachent definitions in JSON. This converts the style name and format to
|
||||
# strings. However, when paperclip encounters these, it doesn't recognise the format.
|
||||
# Here we solve that problem by converting format and style name to symbols.
|
||||
#
|
||||
# eg. {'mini' => ['48x48>', 'png']} is converted to {mini: ['48x48>', :png]}
|
||||
def format_styles(styles)
|
||||
styles_a = styles.map do |name, style|
|
||||
style[1] = style[1].to_sym if style.is_a? Array
|
||||
[name.to_sym, style]
|
||||
end
|
||||
|
||||
Hash[styles_a]
|
||||
end
|
||||
|
||||
def reformat_styles
|
||||
Spree::Image.attachment_definitions[:attachment][:styles] =
|
||||
format_styles(Spree::Image.attachment_definitions[:attachment][:styles])
|
||||
end
|
||||
|
||||
Spree.config do |config|
|
||||
config.shipping_instructions = true
|
||||
config.address_requires_state = true
|
||||
@@ -43,7 +62,7 @@ Spree.config do |config|
|
||||
config.attachment_styles = ENV['ATTACHMENT_STYLES'] if ENV['ATTACHMENT_STYLES']
|
||||
config.attachment_default_style = ENV['ATTACHMENT_DEFAULT_STYLE'] if ENV['ATTACHMENT_DEFAULT_STYLE']
|
||||
|
||||
# update_paperclip_settings
|
||||
# Update paperclip settings
|
||||
if config.use_s3
|
||||
s3_creds = { access_key_id: config.s3_access_key,
|
||||
secret_access_key: config.s3_secret,
|
||||
@@ -65,10 +84,7 @@ Spree.config do |config|
|
||||
Spree::Image.attachment_definitions[:attachment][:default_style] =
|
||||
config.attachment_default_style
|
||||
|
||||
# Spree stores attachent definitions in JSON. This converts the style name and format to
|
||||
# strings. However, when paperclip encounters these, it doesn't recognise the format.
|
||||
# Here we solve that problem by converting format and style name to symbols.
|
||||
Spree::Image.reformat_styles
|
||||
reformat_styles
|
||||
end
|
||||
|
||||
# Spree 2.0 recommends explicitly setting this here when using spree_auth_devise
|
||||
|
||||
Reference in New Issue
Block a user