I have a custom webpart that is displaying dynamic list data, it needs to render an image from a Picture Library (or at least provide me the URL so I can encapsulate it with an tag), however, none of the fields in the Picture Library seem to contain the image URL? Is there a 'image utility' (SPImageUtility) or something I can use to pull this out? Or am I simply missing something?
3
votes
2 Answers
2
votes
Assuming you are using the object model then the you should use this (c#)
SPListItem["EncodedAbsUrl"]
to get the HTML encoded absolute URL of the image (where "EncodedAbsUrl" is the name of the field/column).
To get the unencoded site relative url you can use ServerUrl or FileRef (they appear to return the same)
You can also use EncodedAbsThumbnailUrl to get a thumbnail image.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.aspx