How to Rotate Clickable Images from a Picture Library

A customer contacted our Solutions team this past week seeking the ability to make images from a SharePoint Picture Library rotate on a page and embed a hyperlink from a column in the Picture Library.  While this is not functionality that exists in SharePoint out-of-the-box, Bamboo Solutions offers a product called List Rotator Web Part which will allow users to achieve the desired results.  List Rotator Web Part allows you to rotate information using various animations, and includes the ability to configure a custom layout of list items data to suit your needs through custom HTML and CSS.   For more information about custom Styling of List Rotator, please see the Styling the Web Part section of our Online Documentation site.

For this particular customer's solution, we utilized the custom HTML feature of the Web Part.  Following the directions provided in the Online Documentation mentioned above, we enabled custom Styling and injected the following Source code:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" /> 
<xsl:template match="rs_data">   
<xsl:for-each select="z_row"> 
 <TABLE>       
<TR>
<TD>
<a href="{substring-before(@ows_HyperlinkForPic, ', ')}"><img border="0" src="{@ows_FileRef}" alt="{@ows_FileRef}"/></a>        
</TD>
</TR>
</TABLE>  
 </xsl:for-each> 
</xsl:template>
</xsl:stylesheet>

Note - The above code segment makes the following assumptions:

  1. You are seeking to display the contents of a SharePoint Picture Library in the Web Part.
  2. You have the library and Web Part in a non-Publishing site (different code is required for a Publishing site and will be explained below).
  3. You have created a column in the SharePoint Picture Library of type Hyperlink.  In the above code, this column was called HyperlinkForPic.  If a different column name is used, simply substitute the name accordingly in the code.

If you are using the Web Part in a Publishing site, the structure of the site is slightly different (the home page actually exists in a library called Pages whereas in a Team site it exists outside of libraries).  In this case, the code to use would be:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" /> 
<xsl:template match="rs_data">   
<xsl:for-each select="z_row"> 
 <TABLE>       
<TR>
<TD>
<a href="{substring-before(@ows_HyperlinkForPic, ', ')}"><img border="0" src="../{@ows_FileRef}" alt="../{@ows_FileRef}"/></a>        
</TD>
</TR>
</TABLE>  
 </xsl:for-each> 
</xsl:template>
</xsl:stylesheet>

Where the change is in the FileRef references.  We add a ../ to the front of the reference to retrieve the proper URL of the image.


Posted Sep 01 2009, 12:06 PM by Jeff Kozloff

Comments

Jeff Kozloff wrote re: How to Rotate Clickable Images from a Picture Library
on Tue, Sep 1 2009 1:39 PM

An added tip:

Make sure the columns you want to display in List Rotator are included in the view you select in the tool pane.

Mountain wrote re: How to Rotate Clickable Images from a Picture Library
on Thu, Oct 1 2009 10:01 AM

Hey, Jeff... The list rotator seems to work nicely for stepping through pictures or other items; a couple of ideas for future builds -

(a) Read display time from column - some items might be more wordy than others, setting some for longer display than others would be useful.

(b) Always display 'sticky' items first in Random mode - check a column for an 'important' flag, always display these items first; would be of use for 'newsflashes' etc in the rotator area.

and one that would probably be a little tougher:

(c) Capture the onClick event from the custom link URL and update a Click_counter column, for basic tracking.

Keep up the good work, you guys :)

M.

Add a Comment

Please sign into Bamboo Nation to leave a comment.

About Jeff Kozloff

As Senior Product Manager at Bamboo Solutions, Jeff brings over 12 years of Bamboo experience to the Product Management Team.  Overseeing Web Part and Components Division of the Bamboo Solutions product portfolio (over 40 products), Jeff defines product roadmap, works closely with Sales and Support to improve product stability, and the marketing team for promotion of products through Bamboo Storefront and mailings.

Blogs

    The Bamboo Team Blog
  • Home

Bamboo Nation, Media Sponsor of:

SPTechCon

Subscribe by Email

Syndication

Bamboo Nation Almost Everywhere

Follow Bamboo Nation on:Bamboo Solutions on Facebook

Bamboo Solutions on Google+

Bamboo Solutions on LinkedIn

Bamboo Solutions on Twitter

Bamboo Solutions on YouTube

Bamboo Now in Alltop!

        Featured in Alltop

SharePoint Calendars

SharePoint Calendars

Bamboo Solutions Corporation, 2002-2012