views:

3300

answers:

2

Hi All,

I would like to add a field to a list with displays an Image, but acts as a hyperlink. In other words like the "Hyperlink or Picture" column, but "Hyperlink AND Picture" instead.

Where the two fields you input would be the URL to the image to display, and the URL of the hyperlink.

This must be possible. I notice that the Type (in a document library) column does just that, and also includes the views that are currently being used (in the case of a folder).

Is it possible to duplicate the computed Type field in a document library to read two other fields in the list (which will act as the image url, and the redirect link)? What would the CAML be?

Thanks in advance if anyone could offer any insight.

Arnhem

+2  A: 

This can be done but you would need to develop a custom field type. As you have found, SharePoint's default rendering for pictures is without the hyperlink. You need to change how the rendering behaves in Display mode in your own custom field. Check Patterns in Custom Field Rendering for more info.

There are also several examples of creating custom field types on the web. The MSDN articles give a lot of detail about how it all works but don't let that put you off as it's not too tricky.

Alex Angas
Hi Alex, I exactly did not want to have to create a custom field type, since there are so many additional files then that have to be added. What I did instead was add a new field to the list schema.xml and then (copying the Type column) changed the display pattern.But I'm thinking of adding this display pattern into a custom field now that i understand the process a little better.I've edited my original post to include my new field.
Arnhem
That's a good idea too. You do get more power with a custom field but if editing the list schema.xml works fine it might be better to stick with that. Otherwise you'll have yet another SharePoint artifact to maintain! :)
Alex Angas
A: 

Hi Arnhem, Can you describe little more how you added new field to schema.xml, may be some tutorial how to do it? I have same problem that I want picture in sharepoint also have link in it. Thanks Martin

martin
Know I am responding quite late, but here it is for anyone none the less. In the end I added a URL field:<Field ID="<ID>" Type="URL" ClassInfo="Icon" Name ="ItemImage" Title="ItemImage" DisplayName="Type" Description="Icon representing the item type." Required="FALSE" Format="Image" StaticName="ItemImage">Note the format tag. Then to set this image you have two options (both i did programmatically) - CHECK next comment i post, running out of characters...
Arnhem
Option 1:provide the URL in this format:'/_layouts/images/<image file name>' (this is if you placed the image in the layouts/images folder.)ORalternatively if the file exists in SP (for instance an image library):assign it: SPListItem.SPFile.ServerRelativeUrl, i.e:listItem[columnName] = imageListItem.File.ServerRelativeUrl;That's for an icon without a link, for a method with a link you need a computer field, and this comment box is too small for that. Mail me at [email protected] and i'll email you the field definition.
Arnhem