You select an image in edit mode, all looks good in preview mode but when published, the Image has disappeared.

Upon debugging, the MediaReference property is null.

The problem is due to a delay-loading malfunction in Episerver. There is a built-in function in Episerver that will delay the loading of long string properties when they reach a certain limit. The page will be loaded and the long string properties will be loaded when they are requested.

This works most of the time, but in some cases (root cause unknown, Episerver support have had multiple issues regarding this for years) the delayed loading mechanism fails and instead of retrieving the property from the database, the property returns null instead.

To fix this, you need to disable the lazy loading feature for long string properties by setting the stringDelayedLoadThreshold attribute in web.config.

    <applicationSettings ... stringDelayedLoadThreshold="0" />

When setting the value to 0, it will disable the delayed load and always include all long string properties, regardless of their length.

By default (if not set) the value is 255 and since the data saved in the MediaReference often is longer than this, the property loading will be delayed.