A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

Deepmala S
Jan 16, 2026
  55
(1 votes)

Alt text is retrieved for images imported from CMP-DAM in Optimizely CMS 12.

Introduction

Although image alt text is stored as metadata in CMP/DAM, it is not automatically rendered in browser HTML. This document outlines the solution implemented in Optimizely CMS to retrieve and render this metadata correctly.

Steps : 

1) Create image file class and inherit with ImageData.

public class ImageFile : ImageData
{
    [Display(Name = "Alt text", Order = 10)]
    public virtual string AltText { get; set; }
}

2) Create image file view model

public class ImageFileViewModel
{
    public string AltText { get; set; }
}
 
3) Create image file request and paas in-built DAMAssetIdentity
 
public class ImageFileRequest : IRequest<ImageFileViewModel>
{
    public ImageFileRequest(DAMAssetIdentity damAsset, CultureInfo culture)
    {
        Culture = culture;
        ImageFileReference = damAsset;
    }
    public DAMAssetIdentity ImageFileReference { get; set; }
    public CultureInfo Culture { get; }
}
 
4) Create image file request handler and fetch Alt text from Dam using DAMAssetIdentity metadata

public async Task<ImageFileViewModel> Handle(ImageFileRequest request, CancellationToken cancellationToken)
 {
     if (request?.ImageFileReference != null)
     {
               temp.AltText = request?.ImageFileReference?.Metadata?.DAMAssetInfo?.AltText;
     }
     return temp;
 }
 
5) If in case while fetching alt text from Dam and if we will get DAMAssetInfo is null due to unaxpected behavior then we will use IDAMAssetMetadataService showing below
 
if (temp.Metadata?.DAMAssetInfo == null)
{
           var temp2 = ServiceProviderExtensions.GetInstance<IDAMAssetMetadataService>(ServiceLocator.Current).GetAssetMetadata(ExtractAssetGuid(temp).Value).Result;
        altText = temp2?.AltText;
    }
}


6) After fetching Alt text successfully then we will pass in view.

Above i have added only neccesary code other can add according to requirements.
Below references added for CMP-DAM configuration and assets sync.

Important Links
 
 
Jan 16, 2026

Comments

Please login to comment.
Latest blogs
A day in the life of an Optimizely OMVP: Unlock the Power of Unified Search: Introducing Custom Data Management for Optimizely Graph

Bring all your data together in one searchable experience The Challenge: Siloed Data, Fragmented Search Every organisation has data spread across...

Graham Carr | Jan 16, 2026

Announcing Stott Security Version 4.0

January 2026 marks the release of Stott Security v4, a significant update to the popular web security add-on for Optimizely CMS 12, with more than...

Mark Stott | Jan 16, 2026

Optimizely Graph Best Practices - Content Modelling and Querying

Introduction With the Mando Group team having worked extensively with Optimizely Graph over the last 12+ months, we have uncovered a number of best...

Jon Williams | Jan 16, 2026