function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
cozimekcozimek 

How to render a transparent gif directly from APEX code

Hi folks,

 

We're trying to create a way that would allow a person reading an HTML email to view an image with a path like this:

 

<img src="http://johndoe-dev-developer-edition.na12.force.com/public/?id=123462324" />

 

When that link is accessed, we immediately want the associated APEX code to update the related record, but also immediately display a gif image to the reader.  So far, we've done lots of research but nothing seems to work.

 

We have the base64 code for the image we'd like to display as well, and have tried making a VF page with contenttype="image/gif"

 

Base64 code:  R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==

 

Any ideas or suggestions would be greatly appreciated.

 

Cheers

Pat PattersonPat Patterson

Hi Cozimek,

 

You can include data inline like this in a VF page:

 

<img src="data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="/>

Cheers,


Pat

cozimekcozimek

Hi Pat,

 

Thanks for the fast response.  I just tried putting in the following code into my VF page...

 

<apex:page contentType="image/gif" standardStylesheets="false" showHeader="false" sidebar="false">
<img src="data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="/>
</apex:page>

 

...and I keep getting this error message in Firefox: "The image "http://mydeveloperdomain.na14.force.com/public" cannot be displayed because it contains errors."  Any ideas why we'd keep getting this?  No matter what we try, we always get this response.

 

-Ryan

Pat PattersonPat Patterson

You need to take the contentType="image/gif" out of the page header - then you'll get a VF page with just your GIF on it.

 

Backing up a little - what is it you're trying to achieve - something like a web bug? I'm not sure that's going to work - I don't think there's a way to render binary content as a VF page.

 

I haven't worked with email tracking, but it looks like this is built in for email sent from Salesforce - see https://login.salesforce.com/help/doc/en/email_track.htm

cozimekcozimek

Yeah, that's what we're trying to achieve, but we've built our own app, and would like to render a web bug ourselves for our own app.

 

Hmm...

 

Thanks for your quick thoughts though!

 

-Ryan