You need to sign in to do that
Don't have an account?

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>
<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>
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
I have already tried <apex:image url="{!URLFOR($Action.Attachment.Download, AttachemntId)}" />
Please see line no 9 in my code.