FIX: properly handle images when using 's3_cdn_url'

This commit is contained in:
Régis Hanol
2015-05-26 11:47:33 +02:00
parent 32f91301ef
commit a797f7c664
3 changed files with 8 additions and 2 deletions

View File

@@ -128,7 +128,9 @@ class Upload < ActiveRecord::Base
def self.get_from_url(url)
return if url.blank?
# we store relative urls, so we need to remove any host/cdn
url = url.gsub(/^#{Discourse.asset_host}/i, "") if Discourse.asset_host.present?
url = url.sub(/^#{Discourse.asset_host}/i, "") if Discourse.asset_host.present?
# when using s3, we need to replace with the absolute base url
url = url.sub(/^#{SiteSetting.s3_cdn_url}/i, Discourse.store.absolute_base_url) if SiteSetting.s3_cdn_url.present?
Upload.find_by(url: url) if Discourse.store.has_been_uploaded?(url)
end