1

I have a problem using an Image Field in a Page Layout. What I did was the following:

  1. Created Image Field
  2. Created Content Type (inherited from Article Page)
  3. Added the Field to the Content Type and deployed the solution
  4. Created Page Layout with the Content Type
  5. Generated a snippet for the Image Field

Field:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">  
  <Field
       ID="{4ea31e74-f59d-4ddf-863c-607a01735f65}"
       Name="pls_H2_2_Image"
       DisplayName="Titel 2 Bild"
       Type="Image"
       Required="FALSE"
       Group="Custom">
  </Field>
</Elements>

Generated Snippet (why did the snippet convert > and < ? If I generate the snippet for Page Image (standard article page field) > and < are shown properly):

<div data-name="Page Field: Titel 2 Bild">
    <!--CS: Start Page Field: Titel 2 Bild Snippet--><!--SPM:<%@Register Tagprefix="PageFieldRichImageField" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>--><!--MS:<PageFieldRichImageField:RichImageField FieldName="4ea31e74-f59d-4ddf-863c-607a01735f65" runat="server">--><!--PS: Start of READ-ONLY PREVIEW (do not modify)-->
    <div id="ctl02_label" style="display:none">Titel 2 Bild</div>
    <div id="ctl02__ControlWrapper_RichImageField" class="ms-rtestate-field" style="display:inline" aria-labelledby="ctl02_label">
        <div align="left" class="ms-formfieldcontainer">
            <div class="ms-formfieldlabelcontainer" nowrap="nowrap"><span class="ms-formfieldlabel" nowrap="nowrap">Titel 2 Bild</span></div>
            <div class="ms-formfieldvaluecontainer">
                <div class="ms-rtestate-field">&lt;img alt="" src="/_layouts/images/home.gif" style="BORDER: px solid; "&gt;</div>
            </div>
        </div>
    </div>
    <!--PE: End of READ-ONLY PREVIEW--><!--ME:</PageFieldRichImageField:RichImageField>--><!--CE: End Page Field: Titel 2 Bild Snippet-->
</div>

Snippet Preview (note that in fact no picture is displayed, only the code):

Titel 2 Bild
<img alt="" src="/_layouts/images/home.gif" style="BORDER: px solid; ">

Generates the following (Picture selected in edit-mode then saved the page):

String instead of picture

I also generated the snippet for the Page Image Field (inherited from Article Page) which works without a problem. I don't understand why my custom Image Field doesn't get displayed while the Page Image does (even the preview of the snippet for the Page Image field already shows a picture and no html img code)

Edit: I added two screenshots to clarify my problem, with the hope that someone will understand and help me.

What "Titel 2 Bild" looks like in the preview: What "Titel 2 Bild" looks like in the preview

What "Page Image" looks like (and how "Titel 2 Bild" should look like): enter image description here

1

Finally found the mistake. One property was missing in the field definition: RichText="True"

Full field definition:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">  
  <Field
       ID="{4ea31e74-f59d-4ddf-863c-607a01735f65}"
       Name="pls_H2_2_Image"
       DisplayName="Titel 2 Bild"
       Type="Image"
       Required="FALSE"
       RichText="TRUE"
       Group="Custom">
  </Field>
</Elements>
0

Adding to Razze's reply, it isn't work for me until I added and extra property for the field which is RichTextMode="FullHtml" to be finally like:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">  
 <Field
   ID="{4ea31e74-f59d-4ddf-863c-607a01735f65}"
   Name="pls_H2_2_Image"
   DisplayName="Titel 2 Bild"
   Type="Image"
   Required="FALSE"
   RichText="TRUE"
   RichTextMode="FullHtml"
   Group="Custom">
 </Field>
</Elements>

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.