Welcome to Comunidade Bloggers |create|it| Sign in | Join | Help

Miguel Isidoro

.NET
SharePoint
Tek

News

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="http://blogit.create.pt/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: Sunday, December 09, 2007 9:40 AM by misidoro
Filed under: ,

Comments

No Comments

Anonymous comments are disabled