We do not recommend that you access raw fields on the item directly, we recommend to use our api to retrieve metadata.
The api will return a well define When working with metadata through the API, the recommendation is to use the API rather than working with the item directly.
The API returns a well-defined data model of type AssetMetadata which contains the following properties and methods:
Property name | Type | Description |
---|---|---|
Name | String | The title of the asset. |
Description | String | The description of the asset. |
AssetId | Int | This is a unique id coming descending from the DAM Center. |
AssetTypeId | Int | This is a unique id, representing what kind of type the asset is. E. Exg. The assettype for images equals is 4 and video equals 1 etcthe assettype for videos is 1. This id can be mapped to an item in using this location:system/modules/Digizuite/[silo id]/AssetTypeRoot |
AssetTypeName | String | The name of the asset type. |
AssetSiloId | String | The Sitecore itemId of the silo this in which the asset is part oflocated. |
AssetSiloName | String | The Sitecore item name of the silo this in which the asset is part oflocated. |
ImportedBy | String | The name of the user who uploaded the asset. |
CreatedDateTime | DateTime | The upload date. |
ChangedDateTime | DateTime | The change date. |
Filesize | Long | The file size of the original file in bytes. |
Filesizeabreviated | String | A more readable version of the file size ex. 606.34 KB |
Extension | String | The extension of the original file. |
VideoLength | String | Is If the asset being is of type video, then this is the length of the video. |
VideoWidth | Int | The width of the original file. |
VideoHeight | Int | The height of the original file. |
VideoFps | Float | The frames per seconds of the original file. |
ImageWidth | Int | The width of the original file. |
ImageHeight | Int | The height of the original file. |
ImageDpi | Int | The dpi of the original file. |
DynamicMetadata | IDictionary<string, string> | This dictionary will contain contains all the dynamic metafield metafields from the DAM Center. The key is the MetafieldId of the metafield. All metafields can be found either in DAM Center or at in this location in : Sitecore:system/modules/Digizuite/[silo id]/MetaGroupRoot. |
Method name | Description | Ex. Example of return value |
---|---|---|
GetMediaUrl() | Returns the media URL for the source file. | /media/512ffeba519249ff866095d7a25846ec/1-source |
GetMediaUrl(string mediaFormatId, int resizeWidth = 0, int resizeHeight = 0, bool keepAspectRatio = true, bool allowUpScale = false)) | Returns a media URL for the specified quality (mediaFormatId). You have This gives the opportunity resize the image. By default the keepAspectRation keepAspectRatio is true and allowUpScale is false. | /media/512ffeba519249ff866095d7a25846ec/1-50044/resize/100x0/options/keepaspectratio |
GetDownloadUrl() | Returns the download URL for the source file. | /media/512ffeba519249ff866095d7a25846ec/1-source/options/download |
GetDownloadUrl(string mediaFormatId) | Returns the download URL for the specified quality (mediaFormatId). | /media/512ffeba519249ff866095d7a25846ec/1-50044/options/download |
GetDigizuiteStreamingUrl(string mediaFormatId) | Returns the direct streaming URL to Digizuite. Use this for video streams, can also be used for other types. If you use it for the type image, be aware that it does not use Sitecore cache. The link will contain a access token, which will expire, the default value is 24 hoursfor instance video or images. Please note that using this bypasses the Sitecore cache. Furthermore, the link contains an access token, which expires after some period of time, where the default is 24 hours. Therefore do NOT make the URL static on your pages, since the access token will expire. | https://[DIGIZUITE URL]/Dmm3BWSV3/assetstream.aspx?assetid=23&mediaformatid=50052&destinationid=10010&accesskey=f0b020bc-81e3-4824-82e3-2e6c1d8f714c |
...
Note about mediaFormatId. The valid ids are located at the following path: Sitecore → System → Modules → Digizuite → MetadaraRoot_0 → FormatRoot. It is the complete list of formats available in the Sitecore solution. A format contains different fields for instance MediaFormatId which is the id used in the methods described above.
To see an example of how metadata looks for a specific asset, an admin page has been created. Here all the metadata for a specific asset item can be previewed. It is available on the following path: /sitecore/admin/dfs/GetMetadata.aspx?id=[Item ID]
Below is an example of how it looks:
4.1 How to retrieve metadata from an item placed in the silo bucket
In order to retrieve the metadata for the silo item, call the following pipeline: DFS.GetAssetMetadata
The GetAssetMetadataArgs takes AssetItemId which is of type Sitecore.Data.ID and ContextLanguage which is of type Sitecore.Globalization.Language.
See example below
Code Block | ||||
---|---|---|---|---|
| ||||
var renderArgs = new GetAssetMetadataArgs { AssetItemId = item.ID, ContextLanguage = Sitecore.Context.Language };
CorePipeline.Run(PipelineNames.GetAssetMetadata, renderArgs);
if (renderArgs.AssetMetadata == null)
{
return;
}
var name = renderArgs.AssetMetadata.Name; |
4.2 How to retrieve metadata for the field type Asset
Code Block | ||||
---|---|---|---|---|
| ||||
AssetField assetField = Sitecore.Context.Item.Fields["Asset"];
var name = assetField.AssetMetadata.Name;
var htmlRender = assetField.RenderAsset(); |
...
4.3 How to retrieve metadata for the field type AssetLink
Code Block | ||||
---|---|---|---|---|
| ||||
AssetlinkField assetLinkField = Sitecore.Context.Item.Fields["AssetLink"]; var name = assetLinkField.AssetMetadata.Name; var htmlRenderLink = assetLinkField.RenderAsset(); |
...
4.4 How to retrieve metadata for the field type AssetList
Code Block | ||||
---|---|---|---|---|
| ||||
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"]; } } |
...
4.5
...
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.