In the Content Hub it's possible to select different script types. One of them is Metadata processing script. Metadata processing scripts are executed every time an asset is processed by the processing worker.
The script uses the IMetadataProcessingContext, which can be found here: link to IMetadataProcessingContext
The context has two important properties: Asset and MetadataProperties.
ICultureSensitiveProperty
ICultureInsensitiveProperty
After making all the changes, don't forget to SAVE the asset changes. Otherwise the changes will be discarded. Add the following command to the script, it will save the made changes on the entity.
For more information about manipulating the IEntity, see: link to IEntity
Media processing example:
link to Media processing example
The script uses the IMetadataProcessingContext, which can be found here: link to IMetadataProcessingContext
The context has two important properties: Asset and MetadataProperties.
- The Asset is the IEntity within the DAM. On this asset you can read or change properties, relations and more
- The MetadataProperties contains a dictionary<string, JToken> with the metadata of the file. For instance the EXIF data of the file, etc.
- ICultureSensitiveProperty: properties with a value per culture.
- ICultureInsensitiveProperty: properties that have one value and do not support cultures.
ICultureSensitiveProperty
string title = titleProperty.GetValue<string>();
titleProperty.SetValue("a new title");
ICultureInsensitiveProperty
CultureInfo enUs = CultureInfo.GetCultureInfo("en-US");
string description = descriptionProperty.GetValue<string>(enUs);
descriptionProperty.SetValue(enUs, "a new description");
After making all the changes, don't forget to SAVE the asset changes. Otherwise the changes will be discarded. Add the following command to the script, it will save the made changes on the entity.
await MClient.Entities.SaveAsync(Context.Asset);
For more information about manipulating the IEntity, see: link to IEntity
Media processing example:
link to Media processing example