Search code examples
youtuberuby-on-rails-3.2vimeo

how to show thumbnails for vimeo and youtube embedded links in ruby on rails?


I have embedded the youtube and vimeo links in my site and trying to show the thumbnail of the video as a link to play while on click.

i tried the gem "has_vimeo_video" but it only accepts the vimeo videos.So i want to show the thumbnails of both the videos i.e youtube and vimeo.

Please need solution.

Thanks


Solution

  • I found out yesterday that there was carrierwave-video-thumbnailer which is pretty cool. It basically does what you want

    A thumbnailer plugin for Carrierwave. It mixes into your uploader setup and makes easy thumbnailing of your uploaded videos. This software is quite an alpha right now so any kind of OpenSource collaboration is welcome.

    But you will need to of course include carrierwave into your application. Hopefully this helps

    Carreierwave is an uploader that enables users to upload content in their app, which I think

    Update

    Alternatively you can use embedly which allows you to add embedded media into your application. The API provides a lot response options as can be seen here. In doing so you could do something like:

    $.embedly('http://www.youtube.com/watch?v=_FE194VN6c4',
               {maxWidth: 600,
                   elems: $('#element'),
                 success: function(oembed, dict){
                            alert(oembed.title);
                          });
    

    The elems property is where you want the video to be embedded, so that when the link is pasted in it should embed the video. You need to pass the video url and get it using the jQuery selector from wherever you put your url in your html.

    Your other alternative is to have a look at the following auto_html gem