lib/onebox/engine/youtube_onebox.rb in onebox-1.6.2 vs lib/onebox/engine/youtube_onebox.rb in onebox-1.6.3
- old
+ new
@@ -10,13 +10,13 @@
WIDTH ||= 480
HEIGHT ||= 360
def placeholder_html
if video_id
- "<img src='https://i.ytimg.com/vi/#{video_id}/hqdefault.jpg' width='#{WIDTH}' height='#{HEIGHT}'>"
+ "<img src='https://i.ytimg.com/vi/#{video_id}/hqdefault.jpg' width='#{WIDTH}' height='#{HEIGHT}' #{Helpers.title_attr(video_oembed_data)}>"
elsif list_id
- "<img src='#{list_thumbnail_url}' width='#{WIDTH}' height='#{HEIGHT}'>"
+ "<img src='#{list_thumbnail_url}' width='#{WIDTH}' height='#{HEIGHT}' #{Helpers.title_attr(list_oembed_data)}>"
else
to_html
end
end
@@ -48,13 +48,11 @@
end
end
def video_title
@video_title ||= begin
- url = "https://www.youtube.com/oembed?format=json&url=https://www.youtube.com/watch?v=#{video_id}"
- data = Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response(url).body))
- data[:title]
+ video_oembed_data[:title]
rescue
nil
end
end
@@ -89,9 +87,19 @@
data = Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response(url).body))
data[:thumbnail_url]
rescue
nil
end
+ end
+
+ def video_oembed_data
+ url = "https://www.youtube.com/oembed?format=json&url=https://www.youtube.com/watch?v=#{video_id}"
+ Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response(url).body))
+ end
+
+ def list_oembed_data
+ url = "https://www.youtube.com/oembed?format=json&url=https://www.youtube.com/playlist?list=#{list_id}"
+ Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response(url).body))
end
def embed_params
p = {'feature' => 'oembed', 'wmode' => 'opaque'}