Deepmala S
Jan 16, 2026
  516
(2 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
Bypassing WAF Blocking in Optimizely CMS 11 with Custom Base64 Properties

Introduction As Optimizely developers, we frequently encounter requirements to allow editors to inject third-party scripts into the head or body of...

Amit Mittal | Mar 2, 2026

Inspect SaaS CMS Packages Without Losing Your Sanity (Package Explorer Update)

Optimizely export packages have quietly become more complex. Inline (nested) blocks in CMS 12 and PaaS solutions weren’t always displayed clearly,...

Allan Thraen | Mar 1, 2026 |

Unstoppable: Insights from Optimizely’s 2026 UK Partner day

Over 150 Optimizely partners met in Shoreditch for the 2026 London Partner Kick Off. The theme was very much Opal with a side order of Optimizely's...

Mark Welland | Feb 27, 2026

What you need to run better experiments today

A practical, end-to-end playbook for higher quality A/B tests: conditional activation, targeting, metrics, power, SRM, and decision discipline.

Hristo Bakalov | Feb 27, 2026 |