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?


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).


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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