diff --git a/lib/oneboxer/base_onebox.rb b/lib/oneboxer/base_onebox.rb index c855bc21d..1f25b703d 100644 --- a/lib/oneboxer/base_onebox.rb +++ b/lib/oneboxer/base_onebox.rb @@ -37,6 +37,11 @@ module Oneboxer var.gsub! /https?:\/\//, '//' if var.is_a? String end + # Add wmode=opaque to the iframe src URL so that the flash player is rendered within the document flow instead of on top + def append_embed_wmode(var) + var.gsub! /(src="[^"]+)/, '\1&wmode=opaque"' if var.is_a? String + end + end def initialize(url, opts={}) diff --git a/lib/oneboxer/flash_video_onebox.rb b/lib/oneboxer/flash_video_onebox.rb index 96555b1d7..18719409a 100644 --- a/lib/oneboxer/flash_video_onebox.rb +++ b/lib/oneboxer/flash_video_onebox.rb @@ -2,12 +2,12 @@ require_dependency 'oneboxer/base_onebox' module Oneboxer class FlashVideoOnebox < BaseOnebox - + matcher /^https?:\/\/.*\.(swf|flv)$/ def onebox if SiteSetting.enable_flash_video_onebox - "" + "" else "#{@url}" end diff --git a/lib/oneboxer/youtube_onebox.rb b/lib/oneboxer/youtube_onebox.rb index 6438b2f37..032352e81 100644 --- a/lib/oneboxer/youtube_onebox.rb +++ b/lib/oneboxer/youtube_onebox.rb @@ -8,8 +8,12 @@ module Oneboxer end def onebox - # Youtube allows HTTP and HTTPS, so replace them with the protocol-agnostic variant - super.each { |entry| BaseOnebox.replace_agnostic entry } + super.each do |entry| + # Youtube allows HTTP and HTTPS, so replace them with the protocol-agnostic variant + BaseOnebox.replace_agnostic entry + # Add wmode=opaque to the iframe src URL so that the flash player is rendered within the document flow instead of on top + BaseOnebox.append_embed_wmode entry + end end end end diff --git a/spec/components/oneboxer/flash_video_onebox_spec.rb b/spec/components/oneboxer/flash_video_onebox_spec.rb index 4bedd7409..9a7259f01 100644 --- a/spec/components/oneboxer/flash_video_onebox_spec.rb +++ b/spec/components/oneboxer/flash_video_onebox_spec.rb @@ -14,7 +14,7 @@ describe Oneboxer::FlashVideoOnebox do it "generates a flash video" do expect(@o.onebox).to match_html( - "" + "" ) end end