mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: properly handle images when using 's3_cdn_url'
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user