Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

TIA

share|improve this question

2 Answers 2

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"
share|improve this answer
    
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;

.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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