mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:49:06 +08:00
FEATURE: Add disable_onebox_media_download_controls hidden site setting (#12208)
Uses discourse/onebox@ff9ec90 Adds a hidden site setting called disable_onebox_media_download_controls which will add controlslist="nodownload" to video and audio oneboxes, and also to the local video and audio oneboxes within Discourse.
This commit is contained in:
parent
e3e8fd4f7c
commit
13c2a4886f
|
@ -1591,6 +1591,9 @@ security:
|
|||
send_old_credential_reminder_days:
|
||||
default: 0
|
||||
hidden: true
|
||||
disable_onebox_media_download_controls:
|
||||
default: false
|
||||
hidden: true
|
||||
|
||||
onebox:
|
||||
enable_flash_video_onebox: false
|
||||
|
|
|
@ -5,9 +5,14 @@ module Onebox
|
|||
module Config
|
||||
DISCOURSE_ONEBOX ||=
|
||||
Sanitize::Config.freeze_config(
|
||||
Sanitize::Config.merge(Sanitize::Config::ONEBOX,
|
||||
attributes: Sanitize::Config.merge(Sanitize::Config::ONEBOX[:attributes],
|
||||
'aside' => [:data])))
|
||||
Sanitize::Config.merge(
|
||||
Sanitize::Config::ONEBOX,
|
||||
attributes: Sanitize::Config.merge(
|
||||
Sanitize::Config::ONEBOX[:attributes],
|
||||
'aside' => [:data]
|
||||
)
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -221,18 +221,25 @@ module Oneboxer
|
|||
end
|
||||
|
||||
def self.local_upload_html(url)
|
||||
additional_controls = \
|
||||
if SiteSetting.disable_onebox_media_download_controls
|
||||
"controlslist='nodownload'"
|
||||
else
|
||||
""
|
||||
end
|
||||
|
||||
case File.extname(URI(url).path || "")
|
||||
when VIDEO_REGEX
|
||||
<<~HTML
|
||||
<div class="onebox video-onebox">
|
||||
<video width="100%" height="100%" controls="">
|
||||
<video #{additional_controls} width="100%" height="100%" controls="">
|
||||
<source src='#{url}'>
|
||||
<a href='#{url}'>#{url}</a>
|
||||
</video>
|
||||
</div>
|
||||
HTML
|
||||
when AUDIO_REGEX
|
||||
"<audio controls><source src='#{url}'><a href='#{url}'>#{url}</a></audio>"
|
||||
"<audio #{additional_controls} controls><source src='#{url}'><a href='#{url}'>#{url}</a></audio>"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -385,6 +392,7 @@ module Oneboxer
|
|||
allowed_iframe_origins: allowed_iframe_origins,
|
||||
hostname: GlobalSetting.hostname,
|
||||
facebook_app_access_token: SiteSetting.facebook_app_access_token,
|
||||
disable_media_download_controls: SiteSetting.disable_onebox_media_download_controls
|
||||
}
|
||||
|
||||
options[:cookie] = fd.cookie if fd.cookie
|
||||
|
|
Loading…
Reference in New Issue
Block a user