Making an Image Gallery from the Asset Library: Part 2

August 02, 2012

In the previous part I showed you how to manipulate the Asset Library Thumbnail view, so that it could be used as image gallery. In this part I will do a small update to the code, so that the first image will be used for the gallery.

Adding gallery images

In the first part I created a gallery section which looked like this:

Gallery view with default image

Gallery view with default image

What I want to do is change the default image to the first image of that folder/gallery. To do this, I will make use of the SharePoint REST service and an Ajax call.

Step 1

The first step is to retrieving the first image of our folder.



Creating a new JavaScript function that will be used to do the Ajax call for each gallery.

Step 3

Now that the JavaScript function is created, the function call can be added to the each loop when creating the galleries.


The end result looks like this:

Gallery view result

Gallery view result

Event has still the default image, this is because there are no pictures added to this folder/gallery.