I recently redesigned my picture gallery as part of moving my website to a WordPress powered site. As part of that redesign, I wanted to move my full size picture view to one that uses LightBox JS 2.0. That worked out smashingly until I decided that I wanted the home movies in my gallery to also display in a LightBox frame. Turns out that LightBox is coded to display image files and does not work out of the Box (har har har) for displaying movies.
After a quick google search I stumbled upon the MPOV blog and a post on Lightbox with iframes. I downloaded his script and plugged it in instead of my current lightbox.js file. It worked great to display the movies but wouldn’t display the images because of a bug. To display my Flash movies in the new iFrame LightBox JS v2.0 I just edited the existing link to the Flash created simple HTML file to include the rel=”lightbox” property. The HTML file is simply a file with an embedded Flash movie (.flv) playing file (.swf).
My issue with the new hacked LightBox was that although it now allowed me to define a height for the iFrame and Lightbox, it didn’t support setting the width of the iFrame and the LightBox and it would no longer display the images. So, when my Flash movie would load in LightBox it, depending on its size, would have a scroll bar. You can set the width at the top of the lightbox.js as the iFrameWidth variable but my videos are a variety of sizes so I needed to be able to dynamically set the width for the LightBox/iFrame.
No biggie, though, with the addition of a few lines of code the new Lightbox with iFrames now supports setting the height and width of the iFrame and therefore LightBox and it also now displays images . To pass in the width and height use: rel=”lightbox|WIDTH|HEIGHT”. For instance if you want to display a 640px X 480px movie you would use rel=”lightbox|660|500″ The script automatically adds the defined LightBox border (var = borderSize) x 2 to the width and height.
Download the new LightBox with iFrames Reloaded
Install by changing the extension to .js from .txt and replace your existing lightbox.js file with the new one.
Note: You will need the full LightBox v2.0 installed already which you can download from here.
For an example of using LightBox to open embedded Flash movies and standard JPG images check out our Picture Gallery. Click on one of the movies links from the first page to see an iFrame + LightBox being used to display the Flash Video or one of the thousand pictures for the standard LightBox image usage.