I was bit hesitant to write this blog to be honest as I thought it’s pretty mundane and must be quite known to everyone. And we had the same requirement for the customer. They wanted to show the entity image of a contact in a webresource.
The functionality as already implemented and I was just reviewing the code. However when I checked the code, I found there is quite a bit written to show the image.
- The entityimage field of the account is queried to get the content
- The whole content is then set using <image src=’data:image/png;base64,<content>’ />
Surprising it is but when I told them there is a better way to do it without querying the content and all, many seemed unware of it. Hence I thought this would be of help to someone faced with similar situation.
For entity image field, there is a separate field created called – “entityimage_url” which can be queried as well. Below is the WebAPI query to get the entity image of an account. Same can be used with any other entity.
The final step is to set the image url in the src attribute of the image in webresource. And you can see it in your web resource.
Hope this helps!
Our product offerings:
Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)
CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)
Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)