SharePoint 2010: Integrating Jquery Carousel and ThickBox

SharePoint 2010: Integrating Jquery Carousel and ThickBox

Hi all,

In this article, I will show how to integrate SharePoint Image Library to JQuery jcarousel with Thickbox and make very nice UI.  We can use it in many places like to show Employee Images in Home Page of HR Site and Clicking on Image will zoom the image with some animation effect, like

Clicking on any Image will open the Image like

And the Very good thing is Image is coming from SharePoint 2010 Image Library.

For Implementing these effect I am using following Libraries.

though I am using Managed Client Object Model to access SharePoint Library and Client Object Model does not support RunwithElevatedPriviledge, that’s why I am accessing the Image Library anonymously.

Step 1: Create Picture Library and Enable Anonymous Access

Look at the following URL to Enable anonymous access in SharePoint 2010

Step 2: Create a aspx page which return the URL of Images

How to Read Image URL


        string RealUrl;
        string FinalURL=string.Empty;
        protected void Page_Load(object sender, EventArgs e)

            string siteUrl = "http://localhost:123";

            ClientContext clientContext = new ClientContext(siteUrl);
            SP.List oList = clientContext.Web.Lists.GetByTitle("PicLibrary"); //PicLibrary is the Name of Document Library.

            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = "<View><Query><Where><Geq><FieldRef Name='ID'/>" +
                "<Value Type='Number'>1</Value></Geq></Where></Query><RowLimit>100</RowLimit></View>";
            Microsoft.SharePoint.Client.ListItemCollection collListItem = oList.GetItems((camlQuery));

                listItems => listItems.Include(
                item => item.File,
                item => item.Id,
                item => item["Title"],
                item => item["Description"],
                item => item["ImageCreateDate"]));


            foreach (Microsoft.SharePoint.Client.ListItem listItem in collListItem)
                string imageUrl = siteUrl + listItem.File.ServerRelativeUrl;

                RealUrl= imageUrl.Substring(0, imageUrl.LastIndexOf('/'));
                RealUrl= LargeImgUrl+ "/_t/" + listItem.File.Name.Replace('.', '_') + ".jpg";

                if (FinalURL== string.Empty)
                    FinalURL = RealUrl;
                    FinalURL = FinalURL + "|" + RealUrl;

The above code return the URL of all the Images concatinated with "|".

Note: Remove all the stuffs from Design Page except Page attribute


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication2.WebForm1" %> 

One of the very interesting thing in SharePoint Image Library is when you upload images its path will be like
when you click on image its path will change and image will be zoomed
http://localhost:123/PicLibrary/_w/1.jpg           //Notice _t to _w change


Step 3: Create a SharePoint Web Part / Application Page which will show the Image Slider and Thick Box

Create a HTML Page with following Code: (You can create Web Part/User Control or Application Pages also)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" xml:lang="en-us">
<link href="../style.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="jcarousel/jquery.jcarousel.min.js"></script>
    <link rel="stylesheet" type="text/css" href="jcarousel/tango/skin.css" />

    <script type="text/javascript" src="thickbox/thickbox.js"></script>
    <link rel="stylesheet" type="text/css" href="thickbox/thickbox.css" />
    <script type="text/javascript">

function mycarousel_itemLoadCallback(carousel, state)
    if (state != 'init')
    jQuery.get('WebForm1.aspx', function (data) {
        mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data);

function mycarousel_itemAddCallback(carousel, first, last, data) {
    var items = data.split('|');
    for (i = 0; i < items.length; i++) {
        var item = jQuery(mycarousel_getItemHTML(items[i])).get(0);
        carousel.add(i + 1, item);

function mycarousel_getItemHTML(item)
    var url_m = item.replace(‘/_t’, '_w.jpg');
    return '<a href="' + url_m + '" title="' + url_m + '"><img src="' + url_m + '" width="75" height="75" alt="" border="0"  /></a>';

jQuery(document).ready(function ()
        visible: 6,
        itemLoadCallback: mycarousel_itemLoadCallback



    <div id="wrap">
        <ul id="mycarousel" class="jcarousel-skin-ie7">

Leave a Comment
  • Please add 6 and 6 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
  • Could you paint a more story, a lot of incomprehensible for beginners? For example I do not understand how to create a file WebForm1.asps? In Visual Studio? Attach an example. Where are the files and WebForm1.aspx WebForm1.aspx.cs copy? And so on ....

  • Nescoffe,

    I have already attached the sample with this article, but it not showing.If you click edit this article link,you can see the attachment. anyway, here is the link to download the file...

  • Download the sample application  from


Page 1 of 1 (3 items)