Class: Onebox::Engine::YoutubeOnebox

Inherits:
Object
  • Object
show all
Includes:
Onebox::Engine, StandardEmbed
Defined in:
lib/onebox/engine/youtube_onebox.rb

Constant Summary

Constants included from Onebox::Engine

DEFAULT

Instance Attribute Summary

Attributes included from Onebox::Engine

#timeout, #uri, #url

Instance Method Summary collapse

Methods included from StandardEmbed

add_oembed_provider, add_opengraph_provider, #always_https?, oembed_providers, opengraph_providers, #raw

Methods included from Onebox::Engine

engines, included, #initialize, #options, #options=

Instance Method Details

#placeholder_htmlObject



17
18
19
20
21
22
23
24
25
# File 'lib/onebox/engine/youtube_onebox.rb', line 17

def placeholder_html
  if video_id
    "<img src='https://i.ytimg.com/vi/#{video_id}/hqdefault.jpg' width='#{WIDTH}' height='#{HEIGHT}' #{video_oembed_data.title_attr}>"
  elsif list_id
    "<img src='#{list_thumbnail_url}' width='#{WIDTH}' height='#{HEIGHT}' #{list_oembed_data.title_attr}>"
  else
    to_html
  end
end

#to_htmlObject



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
53
# File 'lib/onebox/engine/youtube_onebox.rb', line 27

def to_html
  if video_id
    "      <iframe width=\"\#{WIDTH}\"\n              height=\"\#{HEIGHT}\"\n              src=\"https://www.youtube.com/embed/\#{video_id}?\#{embed_params}\"\n              frameborder=\"0\"\n              allowfullscreen>\n      </iframe>\n    HTML\n  elsif list_id\n    <<-HTML\n      <iframe width=\"\#{WIDTH}\"\n              height=\"\#{HEIGHT}\"\n              src=\"https://www.youtube.com/embed/videoseries?list=\#{list_id}&wmode=transparent&rel=0&autohide=1&showinfo=1&enablejsapi=1\"\n              frameborder=\"0\"\n              allowfullscreen>\n      </iframe>\n    HTML\n  else\n    # for channel pages\n    html = Onebox::Engine::WhitelistedGenericOnebox.new(@url, @timeout).to_html\n    return if Onebox::Helpers.blank?(html)\n    html.gsub!(/['\"]\\/\\//, \"https://\")\n    html\n  end\nend\n"

#video_titleObject



55
56
57
# File 'lib/onebox/engine/youtube_onebox.rb', line 55

def video_title
  @video_title ||= video_oembed_data.title
end