Skip to main content

Posts

Showing posts with the label Picture Library

Get Image Url from Picture Library Item

public string GetDummyImageUrl(object theItem, string pictureLibrary) { StringBuilder url = new StringBuilder(); SPWeb web = SPContext.Current.Site.RootWeb; DummyIdeaPictures = string.IsNullOrEmpty(DummyIdeaPictures) ? "DummyIdeaPictures" : DummyIdeaPictures; SPListItem listItem = web.Lists[DummyIdeaPictures].GetItemById(Convert.ToInt32(theItem)); url.Append(SPEncode.UrlEncodeAsUrl(listItem.Web.Url)); url.Append('/'); url.Append(SPEncode.UrlEncodeAsUrl(listItem.ParentList.RootFolder.Url)); url.Append('/'); string filename = listItem.File.Name; ImageSize imageSize = ImageSize.Full; if (imageSize == ImageSize.Full) { url.Append(SPEncode.UrlEncodeAsUrl(filename)); } else { string basefilename = Path.GetFileNameWithoutExtension(filename); string extension = Path.GetExtension(filename); string dir = (imageSize == ImageSize.Thumbnail) ? "_t/" : "_w/"; url.Append(dir); url.Append(SPEncode.UrlEncodeAsUrl(basefilename)); url.A...