youtube_embed 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/youtube_embed.rb +22 -18
- data/lib/youtube_embed/version.rb +1 -1
- data/lib/youtube_embed/video_details.rb +1 -1
- metadata +1 -1
data/lib/youtube_embed.rb
CHANGED
@@ -37,27 +37,31 @@ module YoutubeEmbed
|
|
37
37
|
video_id = get_video_id(video_url)
|
38
38
|
if video_id.present?
|
39
39
|
video_details = YoutubeEmbed::VideoDetails.new(video_id)
|
40
|
-
|
41
|
-
|
42
|
-
<div class="
|
43
|
-
<div class="
|
44
|
-
<
|
45
|
-
|
46
|
-
<div class="youtube_embed_details">
|
47
|
-
<div class="youtube_embed_title">
|
48
|
-
<strong>
|
49
|
-
#{video_details.title["__content__"] ? video_details.title["__content__"] : ""}
|
50
|
-
</strong>
|
40
|
+
if video_details.entry !='failed' #invalid video check
|
41
|
+
thumbnails = video_details.thumbnail
|
42
|
+
return %Q{<div class="youtube_embed_video">
|
43
|
+
<div class="youtube_embed_partial_video">
|
44
|
+
<div class="youtube_embed_thumbnail">
|
45
|
+
<img src="#{thumbnails[1]["url"] ? thumbnails[1]["url"] : ""}" />
|
51
46
|
</div>
|
52
|
-
<div class="
|
53
|
-
|
47
|
+
<div class="youtube_embed_details">
|
48
|
+
<div class="youtube_embed_title">
|
49
|
+
<strong>
|
50
|
+
#{video_details.title["__content__"] ? video_details.title["__content__"] : ""}
|
51
|
+
</strong>
|
52
|
+
</div>
|
53
|
+
<div class="youtube_embed_description">
|
54
|
+
#{video_details.description["__content__"] ? video_details.description["__content__"].truncate(185) : ""}
|
55
|
+
</div>
|
54
56
|
</div>
|
55
57
|
</div>
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
</div>
|
60
|
-
|
58
|
+
<div class="youtube_embed_main_video" style="display:none;">
|
59
|
+
<iframe title="YouTube player" width="#{ width }" height="#{ height }" src="http://www.youtube.com/embed/#{ video_id }" frameborder="0" allowfullscreen></iframe>
|
60
|
+
</div>
|
61
|
+
</div>}
|
62
|
+
else
|
63
|
+
return video_url
|
64
|
+
end
|
61
65
|
else
|
62
66
|
return video_url
|
63
67
|
end
|