You are using fancybox v2.0.6 so other solutions can be deprecated.
To achieve what you want, simply, simply do:
1). Download all javascript files in the following order:
- JQuery
- Fancybox js file
- Js fancybox media js file (you'll find this in the helpers directory)
2). Download fssbox css file
3). Set html for each type of object you want to open in fancybox, for example:
Images:
<a class="fancybox" data-fancybox-group="gallery" href="image01.jpg"><img src="image01thumb.jpg" alt="" /></a> <a class="fancybox" data-fancybox-group="gallery" href="image02.jpg"><img src="image02thumb.jpg" alt="" /></a>
If the href your images is something like href='/attachments/76' , fancybox will not know that it is image , because there is no extension (jpg, png, gif). Add the fancybox.image class to your html, for example:
<a class="fancybox fancybox.image" data-fancybox-group="gallery" href="/attachments/76"><img src="thumb76.jpg" alt="" /></a>
Ajax content (html or txt files):
<a class="fancybox fancybox.ajax" data-fancybox-group="gallery" href="sample.html">open ajax 1</a> <a class="fancybox fancybox.ajax" data-fancybox-group="gallery" href="sample.txt">open ajax 2</a>
(note the second class fancybox.ajax ... also, you can use thumbnails instead of text in my example)
External pages via iframe:
<a class="fancybox fancybox.iframe" data-fancybox-group="gallery" href="http://domain.com/page.html">open page in iframe mode</a> <a class="fancybox fancybox.iframe" data-fancybox-group="gallery" href="http://other.com/page2.html">open other page in iframe mode</a>
(pay attention to the second class fancybox.iframe )
Youtube video:
<a class="fancybox" data-fancybox-group="gallery" href="http://www.youtube.com/watch?v=2matH4B9bTo">open youtube video</a>
(note that we do not need to add an additional class, since we use the fancybox media helper)
NOTE : we use the data-fancybox-group="gallery" attribute to set all the items in one gallery (you should set HTML5 DOCTYPE though)
Finally, just use this script:
$(".fancybox").fancybox();
You can add other API parameters, for example:
$(".fancybox").fancybox({
If you also want to use buttons or thumbnails helpers, be sure to download the corresponding js and css files. Also add helpers options to your script like:
$(".fancybox").fancybox( helpers : { buttons : {}, thumbs : { width : 50, height : 50 } } });
LAST NOTE : this is fancybox v2.0.6 +