I'm facing exactly same issue as following page.
Adding mapping to a custom image model in Tridion Reference Implementation
I created a new multimedia schema 'MyImage' and define metadata field on it, and a multimedia link field links to a multimedia component based on it. Then I customized Sdl.Web.DD4T.Mapping.DD4TModelBuilder. I create model class 'MyImage' and added new code to GetMultiMediaLinks() method and added new method GetMyImages(). Now it succeeds to render linked image on a view. But I cannot get metadata value of the multimdeia component because it's not mapped to model property. How can I customize DXA to get metadata of multimedia component linked from multimedia link field?
My DD4TModelBuilder source code is following.
private static object GetMultiMediaLinks(IEnumerable<IComponent> items, Type modelType, bool multival)
{
var components = items as IList<IComponent> ?? items.ToList();
if (components.Any())
{
//Added following code
if (modelType.IsAssignableFrom(typeof(MyImage)))
{
if (multival)
{
return GetMyImages(components);
}
return GetMyImages(components)[0];
}
}
return null;
}
//Added following method
private static List<MyImage> GetMyImages(IEnumerable<IComponent> components)
{
return components.Select(c => new MyImage { Url = c.Multimedia.Url, FileName = c.Multimedia.FileName, FileSize = c.Multimedia.Size, MimeType = c.Multimedia.MimeType }).ToList();
}