Deepmala S
Jan 16, 2026
  478
(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
Optimizely CMS 13 (Pre-release) Visual Builder

This post captures a proof of concept built on an Alloy MVC site upgraded to Optimizely CMS 13 pre-release, focused on Visual Builder, how to model...

Francisco Quintanilla | Feb 11, 2026 |

Personalized User Journeys with Optimizely CMS

Daniel Copping | Feb 10, 2026 |

Optimizely CMS 12 behaving strangely after upgrading from CMS 11

After upgrading from Optimizely CMS 11 to CMS 12, content type changes stopped working due to an assembly version mismatch. This post explains the...

Henning Sjørbotten | Feb 10, 2026 |

Episode 2 of the OMVP Strategy Roundtable is out

AI is everywhere right now. Strategy decks are full of it. Roadmaps promise it. Tools are shipping faster than teams can keep up. But when it comes...

Satata Satez | Feb 10, 2026