Trying to use Visual Studio to add an image/thumbnail column to the schema.xml of a Sharepoint Foundation list (Can't use the Type="Image" as this is Foundation). Any ideas?



In SharePoint Foundation, there is only one option when you need some OOTB column for displaying picture: use 'Hyperlink or Picture' column. This column is represented by SPFieldUrl class, which have DisplayFormat property, which can be either Hyperlink (default) or Image.

In CAML (i.e. in schema.xml), you will need provide following attributes to Field element:

  1. Type="URL"
  2. Format="Image"
  • I did this..created a list item and added a url to the picture which is in the content database but it was displayed. Any ideas? – MikeC Oct 18 '11 at 18:19

In your Schema.xml add this or change your column like below code:

<Field Name="Picture" ID="{6eeec5fa-ed6f-495d-9622-e5362e6925aa}" DisplayName="Picture" Type="URL" Height="150" Width="224"  Format="Image" />

In eventreceiver or User Control or in Feature:

To get value from a URL Field:

SPFieldUrlValue urlField = new SPFieldUrlValue(item["Picture"].ToString());
string description = urlField.Description;
string url = urlField.Url;

To assign to a URL Field:

SPFieldUrlValue urlField = new SPFieldUrlValue();
urlField.Url = "http://www.xyz.com";
urlField.Description = "xyz";
item["Picture"] = urlField;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.