How does one open a youtube video in colorbox?

I have colorbox working with images but not with youtube video.

I have created a hyperlink with class="colorbox cboxElement" and copied the emdedded iFrame code from youtube into the href field - but to no avail.

Anyone know I could be doing wrong?

Comments

troyfandango’s picture

I resolved this by adding class="colorbox-load cboxElement" to the hyperlink and the parameter iframe=true to the href path.

williecoetzee’s picture

Hi there,

I've tried adding a link in one of my Drupal modules but Lightbox comes up printing "Request".

I've been looking at the examples but cannot figure out how this should be done...

This is what I have:

$output = '<a href="http://www.youtube.com/watch?v=G8KqdFxRjmY&feature=rec-LGOUT-exp_fresh+div-1r-2-HM" class="colorbox-load cboxElement">Test</a>';

Where do I put the iframe=true?

Help will be appreciated

Kendall Totten’s picture

I have the same question, did you figure it out? Thanks.

- Kendall Totten

Kendall Totten’s picture

Make sure the colorbox module settings (/admin/settings/colorbox) are both checked off:
-Enable Colorbox load
-Enable Colorbox inline

In my views-view-field--field-videos-value.tpl.php I have:

<a class="colorbox-load" href="http://www.youtube.com/v/<?php print $output; ?>?fs=1&amp;width=640&amp;height=480&amp;hl=en_US1&amp;iframe=true&amp;rel=0">
<img src="http://img.youtube.com/vi/<?php print $output; ?>/1.jpg"/>
</a>

- Kendall Totten

sandwormblues’s picture

Kendall, thanks for your solution. There is no such php file in my views theme directory. Did you create it yourself or was it created automatically somehow by a module?

Kendall Totten’s picture

Hi sandwormblues,
Yes, views-view-field--field-videos-value.tpl.php is a custom template file I created to override the code that is automatically output by drupal. Make sure that if you are using a field template file the name matches the name of your field. You can find out more about Drupal theme hook suggestions here: http://drupal.org/node/1089656

- Kendall Totten

J_Andres’s picture

Hi,

Thanks for your solution, but i can't find the views-view-field--field-videos-value.tpl.php, where must be exactly?

Thanks

bianchi’s picture

Troy, where did you put that code ?

danistil’s picture

I'm assuming you have a content type for videos. What module did you use for to load the YouTube video? Media? Can someone tell me the settings for this field?

Also what did you use for you view?

I appreciate any help!
Thanks in advance!

andrenoronha’s picture

They're not using any module to load the video. Only a simple text input to get the video key.
I was not using too, but now I found this module and it seems to be working: http://drupal.org/project/video_embed_field

miguel’s picture

On a normal Node you can use this code to embed an Youtube-Video with autoplay:
<a class="colorbox-load" href="http://www.youtube-nocookie.com/embed/IislFaomZng?rel=0&amp;autoplay=1&amp;width=700&amp;height=394&amp;iframe=true" title=""><img src="http://img.youtube.com/vi/IislFaomZng/1.jpg" /></a>

Essentially its the same code as starryeyez024 provided but without php-code.

gmasky’s picture

Thanks for this. The code works perfectly in Drupal 7 but in Drupal 6 the colorbox does not load, instead a new window opens. The D6 version is located at the bottom left of the page http://stanislausbandra.in