mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 21:25:24 +08:00
FIX: ensure local images use local CDN when uploads are stored on S3
When the S3 store was enabled, we were only applying the S3 CDN. So all images stored locally, like the emojis, were never put on the local CDN. Fixed a bunch of CookedPostProcessor test by adding a call to 'optimize_urls' in order to get final URLs. I also removed the unnecessary PrettyText.add_s3_cdn method since this is already handled in the CookedPostProcessor.
This commit is contained in:
@ -56,11 +56,20 @@ class UrlHelper
|
||||
no_cdn = SiteSetting.login_required || SiteSetting.prevent_anons_from_downloading_files
|
||||
|
||||
url = absolute_without_cdn(url)
|
||||
url = Discourse.store.cdn_url(url) unless is_attachment && no_cdn
|
||||
|
||||
unless is_attachment && no_cdn
|
||||
url = Discourse.store.cdn_url(url)
|
||||
url = local_cdn_url(url) if Discourse.store.external?
|
||||
end
|
||||
|
||||
schemaless(url)
|
||||
rescue URI::Error
|
||||
url
|
||||
end
|
||||
|
||||
def self.local_cdn_url(url)
|
||||
return url if Discourse.asset_host.blank?
|
||||
url.sub(Discourse.base_url_no_prefix, Discourse.asset_host)
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user