diff options
author | ThibG <thib@sitedethib.com> | 2020-05-03 23:29:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-03 23:29:41 +0200 |
commit | 75b0fa8b760b8829b933b249ac48965abdab15ae (patch) | |
tree | 4b2e5293f15972012c4dc876bb66870d692490d0 /config | |
parent | 9c61dadc0db7009853c6b2345a02c3b219022929 (diff) | |
parent | 89fcd68b7501f81a3e33f6b1abff6fc66f78e04b (diff) |
Merge pull request #1324 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/paperclip.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index 8909678d6..0dd7f8cf8 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -10,9 +10,25 @@ Paperclip.interpolates :filename do |attachment, style| end end +Paperclip.interpolates :prefix_path do |attachment, style| + if attachment.storage_schema_version >= 1 && attachment.instance.respond_to?(:local?) && !attachment.instance.local? + 'cache' + File::SEPARATOR + else + '' + end +end + +Paperclip.interpolates :prefix_url do |attachment, style| + if attachment.storage_schema_version >= 1 && attachment.instance.respond_to?(:local?) && !attachment.instance.local? + 'cache/' + else + '' + end +end + Paperclip::Attachment.default_options.merge!( use_timestamp: false, - path: ':class/:attachment/:id_partition/:style/:filename', + path: ':prefix_url:class/:attachment/:id_partition/:style/:filename', storage: :fog ) @@ -91,7 +107,7 @@ else Paperclip::Attachment.default_options.merge!( storage: :filesystem, use_timestamp: true, - path: File.join(ENV.fetch('PAPERCLIP_ROOT_PATH', File.join(':rails_root', 'public', 'system')), ':class', ':attachment', ':id_partition', ':style', ':filename'), - url: ENV.fetch('PAPERCLIP_ROOT_URL', '/system') + '/:class/:attachment/:id_partition/:style/:filename', + path: File.join(ENV.fetch('PAPERCLIP_ROOT_PATH', File.join(':rails_root', 'public', 'system')), ':prefix_path:class', ':attachment', ':id_partition', ':style', ':filename'), + url: ENV.fetch('PAPERCLIP_ROOT_URL', '/system') + '/:prefix_url:class/:attachment/:id_partition/:style/:filename', ) end |