Reputation: 13558
Here's my application.js file. I'm using the jquery-embedly API:
$(document).ready(function() {
$('a.oembed').embedly({maxWidth:500,'method':'replace'}).bind('embedly-oembed', function(e, oembed){
$('#video_div').append(oembed.thumbnail_url));
});
});
That code doesn't work: the video is not embedded, nor is any thumbnail added to the div
element. However, this code does work normally:
$(document).ready(function() {
$('a.oembed').embedly({maxWidth:500,'method':'replace'}).bind('embedly-oembed', function(e, oembed){
alert(oembed.title);
});
});
Why can't I get the thumbnail to show? Just in case, here is the view:
<div id="video_div"><%= link_to 'video', @video.video_url, :class => 'oembed' %></div>
Upvotes: 0
Views: 454
Reputation: 159115
You don't want to append the thumbnail_url
, you want to append an image tag with an src
attribute of the thumbnail_url
:
$('a.oembed').embedly({maxWidth:500,'method':'replace'}).bind('embedly-oembed', function(e, oembed) {
$("#video_div").append($("<img>", { src: oembed.thumbnail_url }));
});
Upvotes: 1