I have added alternate text metadata on images in the CMS for an out-of-the-box DXA 1.0 (.NET) website and republished the pages, but the alt text is not showing. Where is this data getting lost?
1 Answer
There is a mismatch between the schema XML field name (altText
), and the Image.AlternateText
property semantic mapping.
The non-code way to fix this is to update the XML field name to be alternateText
, which will mean there is an automatic mapping to the AlternateText
property. However be aware that renaming a schema field will remove any existing metadata in components using that schema.
This can also be fixed in code, by simply adding an appropriate mapping to the Image.AlternateText
property:
[SemanticProperty("s:name")]
[SemanticProperty("altText")]
public string AlternateText { get; set; }