Click here to Skip to main content
15,881,844 members
Articles / Productivity Apps and Services / Sharepoint / SharePoint 2013

Picture Thumbnails Web Part (SharePoint 2013)

Rate me:
Please Sign up or sign in to vote.
4.86/5 (7 votes)
3 Jun 2014CPOL3 min read 42.4K   1K   6   16
A SharePoint 2013 web part that uses lightbox to view images from a picture library.

Figure 1

Image 1

Figure 2

Image 2

Introduction

For use in Microsoft SharePoint 2013, this Picture Thumbnails Web Part displays images from a SharePoint Picture Library in a widget-like thumbnail layout (see Figure 1). When a user clicks on a thumbnail, the original image opens up Lightbox style (see Figure 2). This is adapted from my SharePoint 2010 version and offers the following improvements:

  • Support viewing of images bigger than your monitor size.
  • Built-in CSS styling so no more dependency on external CSS.

Background

For images stored in a SharePoint Picture Library, thumbnails are generated by referencing the URL /<Picture Library Url>/_t/<Image Name>_<Image Extension>.jpg. This URL is stored in field EncodedAbsThumbnailUrl. However the thumbnails are too big for my liking. Instead of using some custom HTTP handler to generate thumbnails of smaller size, I decided to use the thumbnails as they are but use them as CSS background images. This way, I can control the "apparent" thumbnail size by sizing the block element associated with the background image, thereby avoiding any aspect ratio issue of just resizing the thumbnail images directly.

Next, I added lightbox functionality to view the original image when user clicks on a thumbnail. There are many implementations or variations of Lightbox and I settled on using Lokesh Dhakar's Lightbox2 because of its compact size and relatively small number of supporting files.

Description

PictureThumbnailsWebPart has the following public properties:

  • SiteUrl - (Site URL) Server relative URL of the site. If left blank, current site is used.
  • ListTitle - (Picture Library Name) Name of a Picture Library.
  • SortField - (Sorting Field) Available options are Name, Title, Created and Modified.
  • SortOrder - (Sorting Order) Available options are Ascending, Descending and Random. When Random is selected, SortField will be ignored.
  • RowLimit - (Maximum Number of Pictures) Default is 0, which means no limit.
  • ShowAsImageSet - (Group Images into a Single Set) Default is false. If set to true, all images will be treated as part of an image set in Lightbox2, allowing previous and next navigation.
  • IncludeJQuery - (Include jQuery?) Should web part include its own jQuery file? Default is true. Set it to false to use your custom master page's jQuery JavaScript file.

The Web Part uses a resource file to store all messages and property attribute UI strings. It demonstrates how to develop a custom class that inherits WebDescriptionAttribute, WebDisplayNameAttribute or CategoryAttribute and returns a localized string from your own Resource Manager.

The supplied Visual Studio 2013 solution includes all the support files you need to build and deploy this Web Part, minus the strong name key file. It makes full use of the built-in SharePoint integration. No more third party tools or custom pre and post build scripts are needed to build the SharePoint solution file.

Installation

Open SharePoint 2013 Management Shell, add solution file QuestechSystems.SharePoint.PTWebPart.wsp using Add-SPSolution like:

Add-SPSolution "C:\_deployment\QuestechSystems.SharePoint.PTWebPart.wsp"

Go to SharePoint 2013 Central Administration/System Settings/Manage farm solutions. Deploy the installed solution to selected web applications. In the site collection where the solution is deployed, activate the Site Collection Feature Questech Systems Picture Thumbnail Web Part. After that, the Picture Thumbnails Web Part (listed under Questech Systems) should be available for you to add to pages.

To control the number of thumbnails per row, specify a fixed width to the web part in the web part properties under Appearance.

Please note that though this web part is licensed under The Code Project Open License, Lightbox2 is licensed separately under Creative Commons Attribution 2.5 License.

History

  • V1.0 - 2014.06.03 - Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Canada Canada
A Microsoft Certified Professional Developer and Technology Specialist.

Experience and expertise in SharePoint 2016 / 2013 / 2010 / 2007.

Role ranges from a developer in a multi-person team to a solution consultant with expert-level skills, leading a project to completion status.

Proven experience working effectively in a team environment and a self-managed environment.

Comments and Discussions

 
QuestionWebpart with thumbnail photos only visible to me Pin
Member 112800819-Dec-16 6:03
Member 112800819-Dec-16 6:03 
QuestionMaintenance Page error Pin
Nbz12829-Sep-16 0:56
Nbz12829-Sep-16 0:56 
QuestionDid everything as you instructed, no lightbox and no row limit Pin
Member 1076911029-Dec-14 22:40
Member 1076911029-Dec-14 22:40 
QuestionHow to add pagination with previous and next buttons? Pin
venkatesu.c@gmail.com15-Dec-14 22:20
venkatesu.c@gmail.com15-Dec-14 22:20 
Questionnot working in SP 2013 Pin
Member 1108400215-Sep-14 6:08
Member 1108400215-Sep-14 6:08 
AnswerRe: not working in SP 2013 Pin
Stephen Huen18-Sep-14 16:26
Stephen Huen18-Sep-14 16:26 
GeneralRe: not working in SP 2013 Pin
Member 1108400219-Sep-14 1:57
Member 1108400219-Sep-14 1:57 
When I add the web part, all that shows on the page is the heading "Picture Thumbnails;" I click to edit the web part and fill out the Site URL and the Picture Library Name to correspond with the Picture Library that is contained in the same sub-site as the page I am add the web part to. URL for the picture library is https://members.osii.com/user-forum/userforumpictures_2011/Forms/USFM_pictures.aspx and the name is User Forum Pictures 2011. When I add this information into the Configuration section and click OK, just the "Picture Thumbnails" shows still. When I save the page, I get the "Sorry, something went wrong" error.

I am not sure what I am doing wrong or missing.

Thanks in advance.
GeneralRe: not working in SP 2013 Pin
Stephen Huen19-Sep-14 6:00
Stephen Huen19-Sep-14 6:00 
GeneralRe: not working in SP 2013 Pin
Member 1108400219-Sep-14 6:08
Member 1108400219-Sep-14 6:08 
GeneralRe: not working in SP 2013 Pin
Stephen Huen19-Sep-14 6:11
Stephen Huen19-Sep-14 6:11 
GeneralRe: not working in SP 2013 Pin
Member 1108400219-Sep-14 6:21
Member 1108400219-Sep-14 6:21 
GeneralThis is not woking in sharepoint 2010 Pin
HarshDamania0610-Jun-14 6:01
HarshDamania0610-Jun-14 6:01 
GeneralRe: This is not woking in sharepoint 2010 Pin
Stephen Huen10-Jun-14 17:10
Stephen Huen10-Jun-14 17:10 
GeneralRe: This is not woking in sharepoint 2013 Pin
HarshDamania0612-Jun-14 4:49
HarshDamania0612-Jun-14 4:49 
GeneralRe: This is not woking in sharepoint 2013 Pin
Stephen Huen12-Jun-14 17:58
Stephen Huen12-Jun-14 17:58 
GeneralMy vote of 4 Pin
AnasHashki4-Jun-14 13:29
AnasHashki4-Jun-14 13:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.