When storing an image on a record, one might think to create a field that has an ‘image’ type as seen below.
This is useful, but when retrieving this image through an API request you’ll be sent base64 and a link to the image with the suffix ‘.download.aspx’ which for some isn’t ideal.
The workaround here is to take a leaf out of the book of the implementation in the Dynamics for Marketing module. Just like how they implemented Hero Image/Card image hosting on an Event record, you can replicate this on any entity. The interface to upload images can be seen below:
To use the custom control that sits on the field you will need the Dynamics for Marketing module. This will include the entity ‘File’, schema name = ‘msdyncrm_file’.
First off, we create a lookup field to the entity of ‘File’. This entity has a URL field which you can use to retrieve the byte array for the image.
On the file record:
Next, to implement a more friendly interface we can use their control on the File lookup field. This is done by changing the properties of the field as below:
You now have a great front-end display of an image gallery and also a way to store images as a byte array in the back end.