Hi, I’m having a problem getting YouTube videos to play in a FancyBox pop-up when they’re in a sidebar. I’ve used both a simple text widget and Video Sidebar Widget to get the YouTube thumbnail into the sidebar, but when clicked the videos just play in the sidebar.
Video Sidebar Widget doesn’t allow you to input the actual URL, just the video ID. With the text widget though, YouTube’s own embed code (inside iframe tags) doesn’t work when clicked. I can, by using <a class=”fancybox-youtube” href etc, get the video to play in the pop-up, but that’s from a text link, not a thumbnail.
Is there any way to get both? Thanks.
You can convert your text link into a linked image. This is standard HTML. Just replace the text with an image tag so it will look like:
<a href="https://www.youtube.com/watch?v=UNIQUE-MOVIE-ID" class="fancybox-youtube"> <img src="http://i4.ytimg.com/vi/UNIQUE-MOVIE-ID/hqdefault.jpg" style="width:100%;height:auto" /> </a>
Other Youtube thumbnail sizes are
http://i4.ytimg.com/vi/UNIQUE-MOVIE-ID/mqdefault.jpgso you can pick the size that is closest to (but preferably at least the same as) your sidebar width. And (obviously) you need to replace UNIQUE-MOVIE-ID with the ID of your Youtube video. This ID is the same as the one used by that video widget…
Hi, thanks for the quick reply. Those addresses don’t actually work. Maybe YouTube changed something. But your reply put me on the right track and I found that this URL does work (at least at the moment) http://img.youtube.com/vi/ID/0.jpg. 0 is the default size (and the biggest) but you can have 1, 2 and 3, which all seem to be the same size.
Thanks for your help.
Sorry, should have put that link (which goes nowhere) in a code box.
- The topic ‘Getting YouTube videos to play from sidebar’ is closed to new replies.