Nested image disappears when editing a link wrapping an image in Experience Editor


Description

The issue happens if a page needs to render the contents of one field inside another one. For example, when using the @Html.Sitecore().BeginField() and @Html.Sitecore().EndField() helpers to wrap an Image field with a General Link field:

@Html.Sitecore().BeginField("Link")
@Html.Sitecore().Field("Image")
@Html.Sitecore().EndField()

Trying to edit the link in Experience Editor makes the image disappear.

Solution

The workaround is to include the haschildren = true parameter to get the content render correctly, for example:

@Html.Sitecore().BeginField("Link", new { haschildren = true })