Note that there are some explanatory texts on larger screens.

plurals
  1. POSharepoint RichImageField set default image
    primarykey
    data
    text
    <p>In my custom page layout I declare a RichImageField</p> <pre><code>&lt;PublishingWebControls:RichImageField id="InteriorHeaderImage" FieldName="InteriorHeaderImage" InputFieldLabel="Header Image" runat="server" DisplayWidth="960" DisplayHeight="242" /&gt; </code></pre> <p>I'm trying to figure out how to set the default image so the control always shows an image even the first time a page is created using the layout.</p> <p>Ideally, I would like a declarative approach for example:</p> <pre><code>&lt;PublishingWebControls:RichImageField id="InteriorHeaderImage" DefaultImageURL="[it should be this easy]" /&gt; </code></pre> <p>It appears that the value property of the control is assigned an ImageFieldValue object which I could probably figure out how to set in a code-behind but this approach seems harder than it should be: <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.fields.imagefieldvalue.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.fields.imagefieldvalue.aspx</a></p> <p>Solution: I finally ended up creating a code behind for my page layout by creating a class file that inherits from Microsoft.SharePoint.Publishing.PublishingLayoutPage as described here: <a href="http://msdn.microsoft.com/en-us/library/bb986729.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb986729.aspx</a></p> <p>The code of course ended up only being a couple of lines: </p> <pre><code>protected void Page_Load(object sender, EventArgs e) { ImageFieldValue imageField = InteriorHeaderImage.Value as ImageFieldValue; if (imageField!=null) { if(string.IsNullOrEmpty(imageField.ImageUrl)) imageField.ImageUrl = "/Style Library/assets/images/img1small.jpg"; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload