XM/XP Connector
Developer Manual
MVC Field Rendering

MVC Field Rendering

If you're using Sitecore MVC for web development, use Sitecore MVC field rendering helpers to output Bynder DAM fields in Razor views. The connector extends Sitecore's renderField pipeline for DAM field types, so selected Bynder assets and derivatives can be rendered through the standard @Html.Sitecore().Field(...) helper.

Render selected field value

Use this for fields where the selected file or link already determines what should be rendered, such as Image [DAM, Single file] and General Link [DAM].

example.cshtml
<!-- Rendering for a "Image [DAM, Single file]" and  "General Link [DAM]" field 
     (has the derivative specified in the field value) -->
 
@Html.Sitecore().Field("Logo")

Render image fields with a derivative

Use the derivative parameter for Image [DAM, Single asset] and Image [DAM, Multi asset] fields. The connector uses this derivative name to find the file that should be rendered for each selected asset.

example.cshtml
<!-- Rendering for a "Image [DAM, Single asset]" and "Image [DAM, Multi asset]" field 
     (specifies a specific derivative to render) -->
 
@Html.Sitecore().Field("Logo", new { derivative = "webimage" })

Override alt text metaproperty

By default, image rendering uses the field configuration's alt text metaproperty. You can override that per rendering by passing altProperty.

example.cshtml
@Html.Sitecore().Field("HeroImage", new { derivative = "webimage", altProperty = "alt_text" })

Add HTML attributes

Additional rendering parameters are passed through as HTML attributes. Underscores are converted to hyphens, so data_asset_source becomes data-asset-source.

example.cshtml
@Html.Sitecore().Field("HeroImage", new {
     derivative = "webimage",
     @class = "hero-image",
     loading = "lazy",
     data_asset_source = "bynder"
})

Render video fields

For Video [DAM] fields, pass a public video derivative. If no derivative is provided, the connector tries original.

example.cshtml
@Html.Sitecore().Field("Video", new {
     derivative = "mp4",
     controls = "controls",
     preload = "metadata"
})

Render DAM general links

General Link [DAM] fields are handled by Sitecore's link field rendering pipeline, extended for the DAM link field types.

example.cshtml
@Html.Sitecore().Field("DownloadLink")

These examples apply to Sitecore MVC rendering. For JSS and Layout Service rendering, see Headless Rendering.