mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Add site setting for domains to never download images from
This commit is contained in:
parent
a6b88d1e7e
commit
b309deef11
4 changed files with 16 additions and 1 deletions
|
@ -87,7 +87,8 @@ module Jobs
|
|||
def is_valid_image_url(src)
|
||||
src.present? &&
|
||||
!Discourse.store.has_been_uploaded?(src) &&
|
||||
!src.start_with?(Discourse.asset_host || Discourse.base_url_no_prefix)
|
||||
!src.start_with?(Discourse.asset_host || Discourse.base_url_no_prefix) &&
|
||||
SiteSetting.should_download_images?(src)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -72,6 +72,16 @@ class SiteSetting < ActiveRecord::Base
|
|||
.first
|
||||
end
|
||||
|
||||
def self.should_download_images?(src)
|
||||
setting = disabled_image_download_domains
|
||||
return true unless setting.present?
|
||||
host = URI.parse(src).host
|
||||
|
||||
return !(setting.split('|').include?(host))
|
||||
rescue URI::InvalidURIError
|
||||
return true
|
||||
end
|
||||
|
||||
def self.scheme
|
||||
use_https? ? "https" : "http"
|
||||
end
|
||||
|
|
|
@ -605,6 +605,7 @@ en:
|
|||
crawl_images: "Enable retrieving images from third party sources to insert width and height dimensions"
|
||||
download_remote_images_to_local: "Download a copy of remote images hotlinked in posts"
|
||||
download_remote_images_threshold: "Amount of minimum available disk space required to download remote images locally (in percent)"
|
||||
disabled_image_download_domains: "A pipe-delimited list of domains from which linked images will never be downloaded."
|
||||
ninja_edit_window: "Number of seconds after posting where edits do not create a new version"
|
||||
post_edit_time_limit: "Amount of time in minutes in which posts can be edited and deleted by the author. Set to 0 to allow editing and deleting posts at any time."
|
||||
edit_history_visible_to_public: "Allow everyone to see previous versions of an edited post. When disabled, only staff members can view edit history."
|
||||
|
|
|
@ -302,6 +302,9 @@ files:
|
|||
test: false
|
||||
default: true
|
||||
download_remote_images_threshold: 20
|
||||
disabled_image_download_domains:
|
||||
list: true
|
||||
default: ''
|
||||
create_thumbnails: true
|
||||
clean_up_uploads: false
|
||||
clean_orphan_uploads_grace_period_hours: 1
|
||||
|
|
Loading…
Reference in a new issue