SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking to create a web part that simply selects a random image from a picture library and displays it. What is the accepted method for accessing images in a picture library?

share|improve this question

There is an example on codeplex: SharePoint Ad Rotator

Introduction: SPAdRotator is a SharePoint Web Part that can randomly display images from a SharePoint library. Images can be displayed either one at a time (a new random image is selected every time the page is loaded), or all images can be displayed while the user is viewing the page (with a configurable transition effect).

share|improve this answer
up vote 0 down vote accepted

I've found the solution through the Microsoft.Sharepoint.SPPictureLibrary class. It is a layer on top of the SPList class, letting you access the pictures in a picture library by manipulating the SPListItems in the library.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.