You need to sign in to do that
Don't have an account?
Problem with html image tag
I have a force.com site with lets say XYZ as the home page. In one of the subsequent pages I am displaying images uploaded in the attachment object of the related record. To display the image, I am forming the url as '/servlet/servlet.FileDownload?file=' + attachmentId;' This works fine when I use the apex image tag to display the images on the site.
However due to another problem, I had to use html image tag. But when I use the html tag, the images don't get displayed. In order to display them, I have to change the url as '/XYZ/servlet/servlet.FileDownload?file=' + attachmentId;'. This works fine in sites but gives error when viewing the site page as a normal VF page when logged in.
Can anyone explain why is difference between apex image and html image? And what are the possible solutions I have to display the images on both sites and VF page?
As of now, I am trying to solve the other problem I am facing using apex image. If that works out, I will use Apex Image tag.
The best practive is not to hard code urls in your page. Use the $Action like following
<img src="{!URLFOR($Action.Attachment.Download, pic.id)}">
All Answers
The best practive is not to hard code urls in your page. Use the $Action like following
<img src="{!URLFOR($Action.Attachment.Download, pic.id)}">