Change the Image tag attribute mapping in Sitecore

Abstract

How to configure attribute mappings on DAM items in Sitecore.

By default, when you click Select in the Insert from DAM pop up, Sitecore generates an Image tag in the Image field.

Choose file to insert pop-up in Insert from Sitecore DAM window
Image field with generated image tag in the Data section of a content hub item

However, you can configure different attribute mappings on the DAM Image tag attribute. You can add as many attribute mappings as you want.

Add a new attribute mapping

To add a new attribute mapping:

  1. Navigate to the /sitecore/system/Modules/DAM/Config/Mapping folder.

  2. Right-click on the folder, click Insert, and then click Attribute. Enter the name for the new item, for example, Title.

  3. On the Content tab, in the Data section, fill in the following fields:

    Field

    Content

    Content Hub Attribute

    The name of the attribute in the Content Hub

    Sitecore Attribute

    The attribute name in the Sitecore Image tag

    Note

    The value in the Sitecore attribute field must follow XML attribute standards. Special characters, such as empty spaces or white spaces, are not allowed.

  4. Click Save.

  5. To verify the attribute and structure in the Sitecore Content Hub, open a browser tab and enter the URL for the attribute entity, for example, https://<your content hub URL>/api/entities/9782.

    Note

    In the example URL, replace 9782 with the ID of the entity item you have selected.

  6. The browser shows the content hub attribute in JSON, for example, Title:

    Example of content hub attribute properties displayed in JSON format

    Note

    If you use multilevel properties, for example, "Description":{"en-us"...}, you must add the property name in the Content Hub Attribute field in Step 3 as, for example, Description.en-us.

Edit an existing attribute mapping

To edit an existing attribute mapping:

  1. Navigate to the /sitecore/system/Modules/DAM/Config/Mapping folder.

  2. Select the attribute you want to change, for example, the Alternative item. On the Content tab, in the Data section, for example, set the Content Hub Attribute field to Filename:

    Definition section on a DAM mapping item showing the Content hub attribute field set to Filename.
  3. Click Save.