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:pageBlock>
    <apex:pageBlockSection >
         <apex:outputText value="https://anil-cse-domain-dev-ed.my.salesforce.com/servlet/servlet.FileDownload?file=00P9000000w8OFIEA2">
        </apex:outputText>
       
        <apex:image title="imagepreview" value="https://anil-cse-domain-dev-ed.my.salesforce.com/servlet/servlet.FileDownload?file=00P9000000w8OFIEA2"/>
        <apex:image url="{!URLFOR($Action.Attachment.Download, '00P9000000w8OFIEA2')}"/>
        <a href="javascript:void(0);" id="00P9000000w8OFIEA2" target="_blank" onclick="window.open('{!$Site.CurrentSiteUrl}'+'servlet/servlet.FileDownload?file=00P9000000w8OFIEA2', '_blank')">FilePreview</a>
        <a href="javascript:void(0);" id="00P9000000w8OFIEA2" target="_blank" onclick="window.open('https://anil-cse-domain-dev-ed.my.salesforce.com/servlet/servlet.FileDownload?file=00P9000000w8OFIEA2', '_blank')">FilePreviewDirectLink</a>
    </apex:pageBlockSection>   
</apex:pageBlock>
</apex:form>
</apex:page>
Scott Haleo 4Scott Haleo 4
Hi Anil,

Take a look here
https://developer.salesforce.com/forums/?id=906F000000099XCIAY

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

If solved kindly mark this.

Regards,
Scott Haleo
Hytechpro
 
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.