2

I have seen few posts regarding the same topic. However, I couldn't resolve the issue what I have.

I have a content schema, which has "Multimedia Link" field. I have created the model as below for my content schema.

[SemanticEntity(Vocab = "http://www.sdl.com/web/schemas/core", EntityName = "TextImage", Prefix = "tim", Public = true)]
public class TextImage:EntityModel
{
    [SemanticProperty("tim:multimedia_link")]
    public Image Multimedia_Link { get; set; }
    [SemanticProperty("tim:title_text")]
    public String Title_Text{ get; set; }

}

Below is my Image Model class:

public class Image :MediaItem
{   
    public override string ToHtml(string widthFactor, double aspect = 0, string cssClass = null, int containerSize = 0)
    {
        throw new NotImplementedException();
    }
}

I have created my own multimedia schema with metadata fields. I have below questions. could you please help me with that?

  1. How to create model for the metadata fields in my Image class? Say for Eg: I have meta fields like (alt_text, height, width)
  2. How to set value for the metadata fields?

Thanks in advance. Jey

2

Model mapping for metadata felds works the same as for content fields; the model mapping considers both when resolving a semantic property name to a field.

The only special thing for Multimedia Components/Schemas is that they don't have a (content) Root Element Name, so the Title of the MM Schema is used as Semantic Entity name (instead of the Schema's Root Element Name as is done for regular Components/Schemas).

To be precise: the MM Schema's title, excluding any whitespace is used.

See, for example, https://github.com/sdl/dxa-modules/blob/master/webapp-net/MediaManager/Models/MediaManagerDistribution.cs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.