In this article I will describe how to implement and use the Galleria jQuery plugin to create a powerful picture carousel within your XPages application
Demonstration
The XPages integration of Galleria is demonstrated here
Download
The demonstration database can be downloaded from the link above or from here
Galleria
Introduction
“Galleria is a JavaScript image gallery framework that simplifies the process of creating beautiful image galleries for the web and mobile devices.”
I came across this carousel while I was researching my talk for IBMConnect 2013Â and I was amazed by the simplicity, how powerful it was and how in depth and easy to understand the help documentation was. This article may be short and sweet because the plugin is that easy to implement!
Take a look at the example page http://galleria.io/
How does it work?
Looking at the documentation page there is a myriad of information on how to make the carousel you really want. The Beginner’s Guide is one of the best I have seen for any plugin. It is a step by step instruction on how to create the carousel in your web page including how to add jQuery.
We have to change that slightly to make the carousel work in our XPage – but only a little….
Download the plugin files from here http://galleria.io/download/
We add the jQuery library and the Galleria library file(s) to the database by adding them to the Web-Contents folder accessible via the package explorer.  (Window–>Show Eclipse Views–>Package Explorer) and drag and drop the two libraries from your computer into the “js” folder. We also add the themes and css files to the WebContent folder in the galleria folder.

We add the libraries to our XPages like this in the source panel
<script src="js/galleria-1.2.8.min.js"></script>
Using the information on the Beginner’s guide we also add the style
<style>
#galleria{ width: 700px; height: 400px; background: #000 }
</style>
as well as the code to load the carousel once the page is loaded
Galleria.loadTheme('galleria/themes/classic/galleria.classic.min.js');
Galleria.configure({
transition: 'fade',
lightbox: true,
imageCrop: true
});
Galleria.run('#galleria');
Once this is added to the page we just need to add some images…..In the beginners guide it staes that we have to just add some images into the galleria DIV
<div id="galleria">
<img src="photo1.jpg">
<img src="photo2.jpg">
<img src="photo3.jpg">
</div>
but in our case we going to pull the pictures from notes documents in a view. In the same way as we did for the prettyphoto lightbox example we are going to add a view as a data source and use a repeat control to add the images to the page itself.
The data source
<xp:this.data>
<xp:dominoDocument var="imageDoc" formName="imageHolder"></xp:dominoDocument>
<xp:dominoView var="imagesView" viewName="images"></xp:dominoView>
</xp:this.data>
and the repeat control placing the images inside the galleria DIV
<div id="galleria">
<xp:repeat id="repeat1" rows="30" value="#{imagesView}" var="imageRepeat">
<xp:image id="Image1">
<xp:this.url><![CDATA[#{javascript:"#{imageRepeat.imagePath}"}]]></xp:this.url>
</xp:image>
</xp:repeat>
</div>
And that is the absolute basic carousel (not that much different from the prettyphoto lightbox really at this point”
So what’s the difference with this one then?
Well it looks different, that is often a deciding factor when trying to impress your customer – which do they prefer the look of?
There are significantly more options to this carousel than the prettyphoto lightbox and this carousel has been optimized for mobile which the prettyPhoto has not (as far as I can tell). Let’s take a look at some of them…
Galleria comes with the following options:
- Theming (allowing the developer to use pre-build settings to change the colors surrounding the carousel and the speed of the show)
- Fullscreen capability
- Responsive mobile view with swipe actions
- An extensive API
In real words what does this mean? It means that you have almost absolute control over everything which happens within the slideshow or within the picture popups. Look at the optional themes as well. There are different themes you can buy which would serve you well if you were trying to implement this in a commercial site or if you just wanted to pump up an internal site.
In my example I have added a number of options to the carousel which give it some features. You should look seriously into the API to see what is possible.
Galleria.loadTheme('galleria/themes/classic/galleria.classic.min.js');
Galleria.configure({
transition: 'fade',
lightbox: true,
showCounter: true,
showInfo: true,
showImageNav: true,
imagePan: true,
imageCrop: true
});
Galleria.run('#galleria');
Demonstration
Check out the demo(s)
The XPages integration of Galleria is demonstrated here