Miguel Isidoro

Blog sobre .NET, Sharepoint e tecnologia em geral.

My Links

Archives

Post Categories

Login

Blog Stats

Blogs Portugueses

Blogs Sharepoint

SharePoint 2007 - Getting URL from Image Field in WCM Web Sites

It is a common scenario in WCM web sites, to have content page images stored in a column of type Image. SharePoint stores this kind of fields in the content database by storing the image HTML markup, storing an <IMG> tag like in the following example:

<IMG src="/PublishingImages/picture.GIF" />

When working in context of a page layout, we can easily include image fields by inserting an Image Field control using SharePoint Designer. However, there are situations where we must use the SharePoint Publishing API and there's where the ImageFieldValue class comes in hand. This class represents an <IMG> tag and its properties. A common situation is when you want to get the Image URL from its HTML markup. This example shows how it can easily be achieved by using the ImageFieldValue class:

public static string getImageUrl(string imageFieldHTMLMarkup)

{

Microsoft.SharePoint.Publishing.Fields.ImageFieldValue image =

new Microsoft.SharePoint.Publishing.Fields.ImageFieldValue(imageFieldHTMLMarkup);

 

return image.ImageUrl;

}

More information about the ImageFieldValue class can be found in the MSDN web site.

posted on Sunday, December 09, 2007 9:41 AM

Title  
Name  
Url
Box Code
Protected by FormShield
Comments