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
OdedHarnivOdedHarniv 

Displaying an attached image

Hello

 

I'm straggling with something I expected to be simple and I can use some help to figure it out.

 

I have an image as an attachment to a Campaign.

I have a VF page that should display this image but can't get it right.

 

I thought putting the Attachment ID in the image src parameter but this seems to be the wrong way.

 

Any advice on how this should be done?

 

Thanks

 

Oded

Best Answer chosen by Admin (Salesforce Developers) 
RArunrajRArunraj

Hi,

 

Below code will display the image in Vf page, No need of putting any instance because it will automatically taken care and also in the file parameter replace with an attachment id

 

<apex:page>

<apex:image value="/servlet/servlet.FileDownload?file=00P90000000foOr"/>

</apex:page>

 

Thanks,

Arunraj

All Answers

Sonali BhardwajSonali Bhardwaj

You need to give folowing URL in src.

 

https://c.ap1.content.force.com/servlet/servlet.FileDownload?file=[Attachement ID]

 

replace c.ap1 with your name space.

RArunrajRArunraj

Hi,

 

Below code will display the image in Vf page, No need of putting any instance because it will automatically taken care and also in the file parameter replace with an attachment id

 

<apex:page>

<apex:image value="/servlet/servlet.FileDownload?file=00P90000000foOr"/>

</apex:page>

 

Thanks,

Arunraj

This was selected as the best answer
OdedHarnivOdedHarniv

Thanks guys