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
  2
(0 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: Learning Optimizely Just Got Easier: Introducing the Optimizely Learning Centre

On the back of my last post about the Opti Graph Learning Centre, I am now happy to announce a revamped interactive learning platform that makes...

Graham Carr | Jan 31, 2026

Scheduled job for deleting content types and all related content

In my previous blog post which was about getting an overview of your sites content https://world.optimizely.com/blogs/Per-Nergard/Dates/2026/1/sche...

Per Nergård (MVP) | Jan 30, 2026

Working With Applications in Optimizely CMS 13

💡 Note:  The following content has been written based on Optimizely CMS 13 Preview 2 and may not accurately reflect the final release version. As...

Mark Stott | Jan 30, 2026

Experimentation at Speed Using Optimizely Opal and Web Experimentation

If you are working in experimentation, you will know that speed matters. The quicker you can go from idea to implementation, the faster you can...

Minesh Shah (Netcel) | Jan 30, 2026