Declaratively Creating Publishing Columns

I recently needed to declaratively create site columns that used the Publishing framework for SharePoint 2010 to provide a clean UI for selection of images and links to drive publishing content. The native Link and Image field types merely provide a text box to include a URL to the link or image, and don't offer any sort of user interface for the user to select the image to be used or content to be linked. The solution here is to deploy your column using the rich HTML field types from the publishing framework (this requires publishing to be enabled on the site/web as a prerequisite).

I searched high and low trying to find documentation on how to provision these field types declaratively, and documentation was sparse. An old forum thread on MSDN got me going in the right direction, even though the post was targeted to MOSS 2007. The trick is to use the same Link and Image field types that you would use without publishing, but to also supply the RichText and RichTextMode attributes as shown below to instruct SharePoint to use the experience from the publishing framework.

Publishing Image Field

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Field
       ID="{609a6675-ee62-432e-a21a-497f9db60c24}"
       Name="CustomImage"
       DisplayName="Image"
       Type="Image"
       Required="TRUE"
       Sealed="TRUE"
       RichText="TRUE"
       RichTextMode="FullHtml"
       Group="Custom Columns">
  </Field>
</Elements>

Publishing Link Field

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Field
       ID="{393a29ab-f26e-4b71-bdbf-c39594c05607}"
       Name="CustomUrl"
       DisplayName="URL"
       Type="Link"
       Required="FALSE"
       Sealed="TRUE"
       RichText="TRUE"
       RichTextMode="FullHtml"
       Group="Custom Columns">
  </Field>
</Elements>