0

I am creating a page layout (without the associated html file) for my custom content type. One of the fields in my content type is a URL (Hyperlink or Picture) which should point to an image.

How do I render that field as an image?

My field is this:

<SharePointWebControls:FieldValue 
  FieldName="574eee3b-9c17-4927-84af-7d9c34677f50" 
  runat="server" />
1

try the following

   <PublishingWebControls:RichImageField FieldName="InteralFieldName" runat="server"/>

You will need to have the following in the top of your page layout.

<%@ Register TagPrefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

When I was trying to discover which one to use, I used SharePoint designer. Deploy what you have to your SharePoint site, Open your Page Layout in SPD and edit in advanced mode, then in the toolbox under Page Fields, you should see your content type fields. By dragging them on the page, you will see how they should be defined.

  • It doesn't work. I tried using the RichImageField, but then when I refresh the page, the page shows error. – niaher Jan 30 '14 at 3:23
  • I see you have worked it out now. I was guessing the field type you were using, which is why I also explained using SharePoint designer to help. – Cann0nF0dder Jan 30 '14 at 9:58
1

I've figured it out. It turns out that when you create site column of type SPFieldUrl, you can specify the SPFieldUrl.DisplayFormat.

This can be done through the UI (Site Settings / Site Columns / Manage Column):

URLField show as picture

And in my page layout I have this:

<SharePointWebControls:UrlField 
  FieldName="0958dec7-9d2b-4964-bfa5-bc8a3d376b21" 
  runat="server" />

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.