How do i connect a media-image to a MediaPointerFile product catalog property via code in litium 7?

How do i connect a media-image to a MediaPointerFile product catalog property via code in litium 7?
Litium version: 7

1 Like

Shouldn’t you use MediaPointerImage for storing MediaImage? They all store Guid as the value, but the UI for selecting file is different, whether you can select only Image or all Files.

To save a value for the field, we can use entity.Fields.AddOrUpdateValue(‘FieldName’, fileSystemId);
To get the value: entity.GetValue(‘FieldName’);
To get the Url from the file/image systemId: use the GetFileUrl or GetImageUrl extensions method for Guid, located under Litium.Foundation.Modules.ExtensionMethods.

1 Like

yes a realised that they are just guid so i solved the problem.
In my case the field is just i this case pointing to an image for other articles the target migiht be a file that isn’t an image that is why we use MediaPointerFile.