DFE 1.0.0 - 2 Modelling Asset Content Types

Digital Assets in Digizuite are exposed in Episerver as IContent of the MediaData variety. This means that they will automatically work along side Episervers own media - and fit into any reference property meant to reference Episerver Media. The integration comes prepackaged with a few default content type models, which enables it to work out-of-the-box, but you can also create your own to customize even more.

Default Content Types

When installed, the integration adds 3 new media content types to Episerver:

  • Digizuite Image (Digizuite.Episerver.Models.Media.Image) that holds any image assets. Inherits from ImageData and implements IDigizuiteImage.
  • Digizuite Video (Digizuite.Episerver.Models.Media.Video) that holds any video assets. Inherits from VideoData and implements IDigizuiteVideo
  • DigizuiteFile (Digizuite.Episerver.Models.Media.DigizuiteFile) that holds any other asset. Inherits from MediaData and implements IDigizuiteDocument

These default content types are used as a hardcoded fallback, when the Digizuite Content Provider tries to determine which Episerver Content Type to return for a given asset. However, if you assign any other content model to an Asset Type in Digizuite, that will take precedence over these.


Implementing your own Content Types for Assets

A very typical task when implementing the integration is to model your own content types for the Digizuite Assets.

Perhaps you already have a custom Image model in Episerver and you want to keep using it? Or maybe you want to make a brand new one for the Digizuite Assets that holds some custom properties on top of the mandatory?

In order to map a locally defined content model to Digizuite, you just have to do 2 things:

  1. Make sure you implement the proper interface (see below).
  2. Add the "DigizuiteType" attribute to the class.

Interfaces

As earlier mentioned it is a requirement that all content models implement either IDigizuiteImage, IDigizuiteVideo or IDigizuiteDocument. These, in turn, implement IDigizuiteContent interface which has a series of required properties.

These properties are metadata that we will always set, from Digizuite - and are needed for the integration to work well. It is properties like Description, ItemID (in Digizuite), AssetType (Digizuite ID), List of Folders, Asset Type Name, Note, AssetSize (size of original asset in bytes), MMUrl (the URL to MediaManager for this asset), Keywords, as well as the source and preview image for the asset.

On top of that, the Image and Video interfaces adds a few additional properties that are specific to provide a good editorial experience for those asset types.

Mapping to an Asset Type ID

Mapping a content model to an asset type is done like this:

Content Type Declaration
 	[ContentType(GUID = "0A89E464-56D4-449F-AEA8-2BF774AB8730")]
    [MediaDescriptor(ExtensionString = "jpg,jpeg,jpe,ico,gif,bmp,png")]
    [DigizuiteType(AssetTypeIds = new[] { GlobalConstants.AssetTypes.Image })]
    public class ImageFile : ImageData, IDigizuiteImage 
    {
        [UIHint(UIHint.Textarea)]
        [CultureSpecific]
        public virtual string Description { get; set; }
		//...
	}

As you can see in this example, the DigizuiteType attribute simply takes 1 parameter which is an int[] containing the ID's of the Asset Type ID's from Digizuite that you want to map. You can find this ID in the DAM Center. By default, for example the Image has ID '4'.
You don't have to set the MediaDescriptor attribute unless you plan on using the same content type for uploads in the regular Episerver media library as well. When a file is uploaded to Digizuite, Digizuite will determine it's type and automatically assign the properly mapped type (or a default) in Episerver.

You can of course inherit from ImageData such as in the above case - but you are also welcome to inherit from the included defaults and simply extend on them with additional properties.

Property Mapping

If you want to map a property in Episerver to a metadata field in Digizuite that's not exposed through the default classes or the interfaces, it's not very hard. Just like with the type mapping, you simply have to create the property in Episerver and then attach the "DigizuiteProperty" attribute to it, indicating what the name of the property in Digizuite is, that you want to map to.

Property Mapping
        [DigizuiteProperty(Name = "Software")]
        [CultureSpecific]
        public virtual string ExifSoftware { get; set; }

In this case, we want to make the field "Exif Software" in Digizuite editable in Episerver. 

Note

Please be aware that only string and IList<string> is supported. Additionally, it is very important to map the Digizuite types to the correct Episerver types. All multi-types (i.e. tree and multicombo types) should go to List<string> and simple types (int, string, etc.) should go to string.

Mapping custom fields

In order for the above property mapping to work, it is important to ensure that Digizuite also sends the specific metadata field to the Episerver integration - and that it's named the same was as specified in the attribute. This is done by customizing the output parameters for the "GetEpiserverAssets" search in the DAM Center, and adding the requested field as an output parameter, while ensuring it's named correctly.

You can read more about adding custom input and output parameters here: https://digizuite.atlassian.net/wiki/spaces/DD/pages/799604821/DFE+1.0.0+-+6+Customizing+input+and+output+metadata


Blob mapping

As we know, Digizuite automatically produces a defined set of Media formats for each asset. These media formats can also be exposed directly as Blob properties in Episerver.

        [DigizuiteMediaFormat("Small")]
        [ScaffoldColumn(false)]
        public virtual Blob Small { get; set; }

This can simply be achieved by assigning the DigizuiteMediaFormat attribute to a Blob property in Episerver. The attribute should either contain part of the name of the media format, or the media format ID.

A cool benefit of this is that by assigning a blob, due to Episervers convention, you'll also get a pretty url pointing directly to that media format, like this: "/globalassets/digizuite/155-las-vegas.JPG/small".

Read more about Asset URL's here: https://digizuite.atlassian.net/wiki/spaces/DD/pages/799768707/DFE+1.0.0+-+8+Customizing+Asset+Urls