Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Display a Base 64 image in CRM

(0) ShareShare
ReportReport
Posted on by

I have created a basic HTML file

<HTML>
    <HEAD>
        <TITLE>Display Image</TITLE>
        <META charset=utf-8>
    </HEAD>
    <img alt="" src="data:image/png;base64,R0lGOD...base64 code" />
</HTML>

If I save the file to my desktop, then double click it the webpage opens in IE and displays a logo.

If I now add this as a webresource within Dynamics CRM the logo displays as a black square with a white cross in it - whats going on?

All I am trying to do is read the Base64 from a related entity and as the data in the entity changes display the related image.

As always any help appreciated.

Matt

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: Display a Base 64 image in CRM

    Hi,

    No its the Base64 that I have for the image and trying to display that.

    Currently only way to display an image is to upload the image as a webresource - but as soon as I update the source for that image, it dissapears and no new mage is displayed.

    Matt

  • Suggested answer
    Flydancer Profile Picture
    1,332 on at
    RE: Display a Base 64 image in CRM

    If it's a filepath / URL you don't have to add "data:image/png;base64,", just set the path as src

  • Community Member Profile Picture
    on at
    RE: Display a Base 64 image in CRM

    Hi Stefan,

    The code is very similar to what I had prior to creating a HTML webresource, however, adding the above as is goes through the motion - at least it doesn't error - but no image is displayed.

    Regards,

    Matt

  • Suggested answer
    StefanS365 Profile Picture
    3,575 Most Valuable Professional on at
    RE: Display a Base 64 image in CRM

    Here is a post with the solution: How to Display Image ... on Web Client In Dynamics 365

    community.dynamics.com/.../how-to-display-image-saved-using-pen-control-on-web-client-in-dynamics-365

  • Community Member Profile Picture
    on at
    RE: Display a Base 64 image in CRM

    Figured it partly out, I was editing the webresource directly in CRM and then saving it; I hadn't noticed that it was adding a Body tag in and because of this displayed the black box and white cross.  Creating the file in notepad and uploading that to CRM the logo is displayed as expected.

    Now I have some code:

                       var fileContents = "data:image/png;base64," + photodata;

                       var img = document.getElementById("WebResource_img");

                       img.src = fileContents;

    This should upload the latest image when the record changes, all that happens is the existing logo disappears and is not replaced.

    I've outputted the img.src as a string prior to updating it; now it is a path to the image as a file within CRM itself and after updating the string through the above code it it is set to the string in the original file.

    I'm  a little lost with what it is doing.

    Matt

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans