Skip to content

Commit 51837e1

Browse files
author
Tony Guntharp
committed
Merge pull request #202 from oponder/add_youtube_embed
Issue #196
2 parents 804b508 + b80f097 commit 51837e1

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

app/assets/javascripts/backbone/plugins/youtube_embed.js.coffee

+5-7
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ class Kandan.Plugins.YouTubeEmbed
66

77
template: _.template '''
88
<div class="youtube-preview">
9-
<a target="_blank" class="youtube-preview-link" href="<%= videoUrl %>">
10-
<img class="youtube-preview-image" src="<%= thumbUrl %>" />
11-
</a>
9+
<iframe width="560" height="315"
10+
src="http://www.youtube.com/embed/<%= videoId %>"
11+
frameborder="0" allowfullscreen>
12+
</iframe>
1213
<div class="name"><%= subtitle %></div>
1314
</div>
1415
'''
@@ -24,18 +25,15 @@ class Kandan.Plugins.YouTubeEmbed
2425
else
2526
# Spaces indicate a subtitle
2627
comment = $.trim(message.content.substr(message.content.indexOf(" ") + 1));
27-
videoUrl = message.content.split(" ")[0]
2828

2929
videoId = message.content.match(@options.idRegex)[1]
30-
thumbUrl = "http://img.youtube.com/vi/#{ videoId }/0.jpg"
3130

3231
subtitle = null
3332
subtitle = "Youtube: #{comment}" if comment? and comment.length > 0
3433
subtitle ||= videoUrl
3534

3635
message.content = @options.template({
37-
videoUrl: videoUrl,
38-
thumbUrl: thumbUrl,
36+
videoId: videoId,
3937
subtitle: subtitle
4038
})
4139
return Kandan.Helpers.Activities.buildFromMessageTemplate(message)

0 commit comments

Comments
 (0)