Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

4.1 Accessing metadata

On each of the three DFS field types AssetAssetLink and AssetList, have a property called AssetMetadata which exposes the metadata of an asset. AssetMetadata model contains the following properties:

Property name

Type

Description

Name

String

The title of the asset.

Description

String

The description of the asset.

AssetId

String

This is a unique id coming from the DAM Center.

AssetTypeId

String

This is a unique id, representing what kind of type the asset is. Ex. images equals 4 and video equals 1 etc. This id can be mapped to an item in this location:system/modules/Digizuite/[silo id]/AssetTypeRoot

AssetTypeName

String

The name of the asset type.

ImportedBy

String

The name of the user who uploaded the asset.

CreatedDateTime

DateTime

The upload date.

VideoLength

String

Is the asset being of type video, this is the length of the video.

DynamicMetadata

IDictionary<string, string>

This dictionary will contain all the dynamic metafield from the DAM Center. The key is the MetafieldId of the metafield. All metafields can be found either in DAM Center or at this location in Sitecore:system/modules/Digizuite/[silo id]/MetaGroupRoot.

3.5.1 How to retrieve metadata for the field type Asset


AssetField assetField = Sitecore.Context.Item.Fields["Asset"]; 
var name = assetField.AssetMetadata.Name; 
var htmlRender = assetField.RenderAsset();


AssetlinkField assetLinkField = Sitecore.Context.Item.Fields["AssetLink"]; 
var name = assetLinkField.AssetMetadata.Name; 
var htmlRenderLink = assetLinkField.RenderAsset();

3.5.3 How to retrieve metadata for the field type AssetList


AssetlistField assetList = Sitecore.Context.Item.Fields["AssetList"];
if (assetList != null)
{
	foreach (var asset in assetList.Assets)
		{
		// To request the rendering html for the asset you call the
		// RenderAsset method. It returns an RenderFieldResult object
		var renderResultItem = asset.RenderAsset(); 
		var title = asset.AssetMetadata.Name;
		var id = asset.AssetMetadata.AssetId;
		var assetTypeId = asset.AssetMetadata.AssetTypeId;
		var assetTypeName = asset.AssetMetadata.AssetTypeName; 


		// Get dynamic metadata
		var someDynamicMetadata = asset.AssetMetadata["50343"];
	}
}

3.5.4 Update asset metadata not supported from code

Updating an items metadata is not supported from code. Use the editor in the DAM Explorer or Asset browser.

  • No labels