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
Anil Kumar RelliAnil Kumar Relli 

Unable to display attachment as image on apex page. I donot want to download the attachment. Need a preview of it. Please help me.

<apex:page standardController="Attachment" extensions="displayImageExtension">
<c:SiteHeader ></c:SiteHeader>
<apex:form >
    <apex:pageBlockSection >
         <apex:outputText value="">
        <apex:image title="imagepreview" value=""/>
        <apex:image url="{!URLFOR($Action.Attachment.Download, '00P9000000w8OFIEA2')}"/>
        <a href="javascript:void(0);" id="00P9000000w8OFIEA2" target="_blank" onclick="'{!$Site.CurrentSiteUrl}'+'servlet/servlet.FileDownload?file=00P9000000w8OFIEA2', '_blank')">FilePreview</a>
        <a href="javascript:void(0);" id="00P9000000w8OFIEA2" target="_blank" onclick="'', '_blank')">FilePreviewDirectLink</a>
Scott Haleo 4Scott Haleo 4
Hi Anil,

Take a look here

Also Use <apex:image url="{!URLFOR($Action.Attachment.Download, AttachemntId)}" />

If solved kindly mark this.

Scott Haleo
Anil Kumar RelliAnil Kumar Relli
Hi Scott,
I have already tried <apex:image url="{!URLFOR($Action.Attachment.Download, AttachemntId)}" />

Please see line no 9 in my code.