DFO 3.1.0 - 2 Modelling Asset Content Types

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

Default Content Types

When installed, the integration adds three new media content types to Optimizely:

  • 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 Optimizely 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. Either you extend one of our three media models (image, video, or DigizuiteFile) or you implement your own media with our interfaces (IDigizuiteImage, IDigizuiteVideo or IDigizuiteDocument). Perhaps you already have a custom image model in Optimizely and you wish to keep using it - or maybe, you want to make a brand new one for the Digizuite assets that holds custom properties on top of the mandatory ones.

Use interfaces

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

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

As mentioned earlier, it's a requirement that all content models implement either IDigizuiteImage, IDigizuiteVideo, or IDigizuiteDocument. These, in turn, implement the 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's properties like Description, ItemID (in Digizuite), AssetType (Digizuite ID), List of Folders, Asset Type Name, AssetSize (size of original asset in bytes), MMUrl (the URL to MediaManager for this asset) as well as the source and preview image for the asset.

On top of that, the image and video interfaces add a few additional properties that are specifically 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 
    {
        public virtual string Description { get; set; }
        public virtual int ItemId { get; set; }
        public virtual int AssetType { get; set; }
        public virtual string AssetTypeName { get; set; }
        public virtual IList<ContentReference> Folders { get; set; }
        public virtual int AssetSize { get; set; }
        public virtual string MMUrl { get; set; }
        public virtual IList<string> Keywords { get; set; }
        public virtual Blob Source { get; set; }
        public virtual string CropName { get; set; }
        public virtual ContentReference ParentImage { get; set; }
        public virtual int ImageWidth { get; set; }
        public virtual int ImageHeight { get; set; }
        public virtual DateTime LastPublished { get; set; }

        [DigizuiteMediaFormat("imagePreview", "7FB6D99B-9D25-4FB3-831F-B6C51AC08782")]
        public virtual Blob Preview { get; set; }

        [DigizuiteMediaFormat("thumb", "E579A06D-EA32-451F-A3D3-B937224C2FFA")]
        [ImageDescriptor(Height = 48, Pregenerated = true, Width = 48)]
        public override Blob Thumbnail
        {
            get
            {
                return base.Thumbnail;
            }
            set
            {
                base.Thumbnail = value;
            }
        }
	}

As you can see in this example, the DigizuiteType attribute simply takes one parameter which is an int[] containing the IDs of the Asset Type IDs from Digizuite DAM 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 Optimizely media library as well. When a file is uploaded to Digizuite DAM, the Digizuite DAM will determine its type and automatically assign the adequate mapping type (or a default one) in Optimizely. This is the bare minimum which needs to be implemented. It is important with the annotation for Preview and Thumbnail otherwise the images won't be mapped correctly with content from Digizuite. See Blob mapping 

Extending existing media types

A more simple way is to extend one of our default media types and add additional properties. In the example below we extend the image and add a custom blob image. In this case the image "quality" is named "Small" which corresponds to a specific media format in the DAM Center.

[ContentType(DisplayName = "Extended Digizuite Image", GUID = "0af71ce8-1e4b-499b-bf24-24e7fce44121")] 
[DigizuiteType(AssetTypeIds = new[] {GlobalConstants.AssetTypes.Image})]
public class ExtendedDigiImage : Image 
{
	[ScaffoldColumn(false)]
    [DigizuiteMediaFormat("ImageSmall", "3C95F58F-5DD7-4AFB-B1C8-48E05901CE6D")]    
    public virtual Blob Small { get; set; } 
}

Property Mapping

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

Property Mapping
        [DigizuiteMetafield("Description", "C8BB4AF3-1598-4EA4-8D7A-98D54EEAD977")]
        [CultureSpecific]
        public virtual string Description { get; set; }

In this case, we want to make the field "Description" in Digizuite DAM usable in Optimizely.

The following Optimizely types are supported. Additionally, it is very important to map the Digizuite types to the correct Optimizely types. The table below shows the mapping between Optimizely and Digizuite types.

Episerver typeDigizuite typeEditable
BoolBitYes
DateTimeDateTimeYes
StringString, float, link, note, uniqueVersionYes
IList<string>Tree, combovalue, multicombovalueNo
IList<string>editcombovalue, editmulticombovalueYes
IntIntYes

Mapping custom fields

In order for the above property mapping to work, it is important to ensure that the Digizuite DAM also sends the specific metadata field to the Optimizely integration - and that it's called the same 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 is 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 Optimizely.

[ScaffoldColumn(false)]
[DigizuiteMediaFormat("ImageSmall", "3C95F58F-5DD7-4AFB-B1C8-48E05901CE6D")]        
public virtual Blob Small { get; set; }

This can be achieved by simply assigning the DigizuiteMediaFormat attribute to a Blob property in Optimizely. You have to apply the json ID and the GUID of the media format. This requires that the media format has been added to the output parameters for the "GetEpiserverAssets" search in the DAM Center.

A cool benefit of this is that by assigning a blob, due to Optimizely convention, you'll also get a pretty URL pointing directly to that media format, like this: "/globalassets/digizuite/155-las-vegas.JPG/Small" and we ensure the correct MIME type when requesting the asset.

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