...
Below is an example of how it looks:
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.
...
Code Block |
---|
language | c# |
---|
linenumbers | true |
---|
|
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; |
Code Block |
---|
language | c# |
---|
linenumbers | true |
---|
|
AssetField assetField = Sitecore.Context.Item.Fields["Asset"];
var name = assetField.AssetMetadata.Name; |
Code Block |
---|
language | c# |
---|
linenumbers | true |
---|
|
AssetlinkField assetLinkField = Sitecore.Context.Item.Fields["AssetLink"];
var name = assetLinkField.AssetMetadata.Name; |
Code Block |
---|
language | c# |
---|
linenumbers | true |
---|
|
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"];
}
} |
Updating an items metadata is not supported from code. Use the editor in the DAM Explorer or Asset browser.