How to show pictures from Image Library in SharePoint 2010?
Hell0 SharePointers,
If you want to show images from picture library in a custom web part,we can use a Server side object model to achieve this business requirement. In this article, I will give you a piece of code to display images form the Image Library. Image Library is a document library which is used to store images with meta data contents such as Title,Description and Image.
SPWeb spweb= SPContext.Current.Web;
//Get the Image Library in the SharePoint 2010
SPPictureLibrary pictures = (SPPictureLibrary)spweb.Lists[“MY Custom Photos”];
int imageCount= pictures.ItemCount;
string picsource = spweb.Url + “/” + pictures.Items[0].Url;
//Create a Image object and set the height and width
var image = new Image();
image.ImageUrl = picsource ;
image.Height = 200;
image.Width =200;
//Add this control in the Sharepoint web part page.
this.Controls.Add(image);
The above piece of code should be added to the createchildcontrols() method.
Please check out my blog to show pictures from Image Library in SharePoint 2010/2013
Happy SharePointing folks !! 🙂