ImageFieldValue.ImageUrl Property

Gets or sets the URL of the image for this ImageFieldValue object.

Namespace:  Microsoft.SharePoint.Publishing.Fields
Assembly:  Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)

public string ImageUrl { get; set; }

Property Value

Type: System.String
The URL of the image for this ImageFieldValue object. Default is an empty string, which means that the entire value is considered empty.
The value of this property is the src attribute of the <IMG> tag in the ToString output.

This property can be any absolute or server-relative image reference, although some invalid values may be removed when the value is stored in an SPListItem field value.

This is the primary data element for this field value. If this URL does not have a value, all other data in this object is ignored and the ToString method returns an empty string.

// You can change any of the following data that are set into the ImageFieldValue
private const string NewImageUrl = "/SiteCollectionImages/SampleImage.jpg";
private const string NewHyperlink = "/Pages/SamplePage.aspx";
private const bool NewOpenHyperlinkInNewWindow = true;
private const string NewAlignment = "right";
private const string NewAlternateText = "Sample alternate text for the image";
private const int NewBorderWidth = 4;
private const int NewHeight = 100;
private const int NewWidth = 150;
private const int NewHorizontalSpacing = 10;
private const int NewVerticalSpacing = 15

This example is part of the larger ImageFieldValue sample in the ImageFieldValue topic.