Fancybox gallery

From MoodleDocs

With a Picture field called Image (if you prefer another name you need to change the tags in the view html accordingly) create a Grid view named Gallery (if you prefer another name etc.) with the following html in the Repeated entry template:

<xdiv class="entry">
<xdiv style="text-align: center; width: 100px; height: 100px;" class="imageTn">||Image||</xdiv>
<xdiv class="imageHref"><xspan class="hide">||Image:url||</xspan></xdiv>

(remove x from html tag names)

Now all that remains is to add the Fancybox related javascript and css in the respective tabs.

The Fancybox is a library that you can download from The download zip contains a folder titled fancybox which files that you need to extract and store somewhere accessible. One approach is to create a folder recourse on your site and add the fancybox files there.

Then you need to add the following javascript in the javascript tab. Note the reference to jquery from googleapis. You can have a local copy and reference it instead.

Included external js:

And js code:

YUI().use('node', function (Y) {

  if ('.dataformview-Gallery')) {
       var thisView ='.dataformview-Gallery');
       // Link the thumbnails
       var entries = thisView.all('.entry');
           var imgHolder ='.imageTn');
           var imgTn ='img');
           var imgHref ='.imageHref span').get('innerHTML');
           var link = Y.Node.create('<a class="myGallery" rel="gallery" href="'+imgHref+'"></a>');
   $(document).ready(function() {
           'transitionIn'    :    'elastic',
           'transitionOut'    :    'elastic',
           'speedIn'        :    600,
           'speedOut'        :    200,
            'overlayShow'    :    true,
           'opacity'    :    true,
           'cyclic'    :    true


Then add reference to the fancybox css in the css tab.

Included external css: