Class: Onebox::Engine::YoutubeOnebox
Constant Summary
DEFAULT
Instance Attribute Summary
#errors, #timeout, #uri, #url
Instance Method Summary
collapse
add_oembed_provider, add_opengraph_provider, #always_https?, oembed_providers, opengraph_providers, #raw
all_iframe_origins, engines, included, #initialize, #options, #options=, origins_to_regexes
Instance Method Details
#placeholder_html ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/onebox/engine/youtube_onebox.rb', line 16
def placeholder_html
og = get_opengraph.data
if video_id || list_id
"<img src='#{og[:image]}' width='#{WIDTH}' height='#{HEIGHT}' title='#{og[:title]}'>"
else
to_html
end
end
|
#to_html ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/onebox/engine/youtube_onebox.rb', line 26
def to_html
if video_id
<<-HTML
<iframe width="#{WIDTH}"
height="#{HEIGHT}"
src="https://www.youtube.com/embed/#{video_id}?#{embed_params}"
frameborder="0"
allowfullscreen>
</iframe>
HTML
elsif list_id
<<-HTML
<iframe width="#{WIDTH}"
height="#{HEIGHT}"
src="https://www.youtube.com/embed/videoseries?list=#{list_id}&wmode=transparent&rel=0&autohide=1&showinfo=1&enablejsapi=1"
frameborder="0"
allowfullscreen>
</iframe>
HTML
else
html = Onebox::Engine::AllowlistedGenericOnebox.new(@url, @timeout).to_html
return if Onebox::Helpers.blank?(html)
html.gsub!(/['"]\/\//, "https://")
html
end
end
|
#video_title ⇒ Object
54
55
56
|
# File 'lib/onebox/engine/youtube_onebox.rb', line 54
def video_title
@video_title ||= get_opengraph.data[:title]
end
|