My question is about rendering image using its base64 instead of src attribute. I have a rich text field where users can attach images. I am displaying these images in a visualforce page. How can I render the images with base64 instead of regular src attribute?
Here's my apex code:
public List<SObject> getResults () {
Id id = ApexPages.currentPage().getParameters().get('id');
List<SObject> results = [SELECT Id,
Name,
Screenshot__c
FROM myCustomObject__c
WHERE parent__c = :id];
return results;
}
And here's my visualforce:
<apex:repeat var="v" value="{! results }">
<div class="styleclass">
{! v.Name}
</div>
<h3>Screenshot</h3>
<div class="styleclass">
<apex:outputField value="{! v.Screenshot__c}"/>
</div>
</apex:repeat>
The above visualforce snippet renders the images, giving me something like this:
<p><img src="https://mydomain.documentforce.com/servlet/rtaImage?eid=imageid&feoid=someid&refid=someid" alt="myimage.png"></img></p>
Instead of this, how can I get base64 of an image? Something like this:
<img alt="my image" src="data:image/png;base64,{base64dataofImage}/>
Appreciate your help on this!