Accessing an Image from Sites, stored in a Rich Text Area field

Are you sure the rich text field is visible to the site profile? It's not included in the regular list, you have to go to the site settings and access the profile from there where you can then check whether the field level security is good. I assume it is since you have the URL , but then I don't know why you can't access the image. Have you tried using straight tags instead of using the Visualforce image tag?

We use rich text fields for our website and that displays images from the same server without problems; the image below is accessed via this URL:

http://www.spkeasey.com/servlet/rtaImage?eid=a0Fi0000000BX4l&feoid=00Ni0000000GnlW&refid=0EMi00000008S3k

CrowdGuide Logo served up from a RTA

I suspect that you might need to modify the domain part of your image URL to use that of your site, as it is the URL will be for internal access and the site user wouldn't have access to it. You can get the site base URL using: {!$Site.CustomWebAddress}, for example I get the URL of static resources on our site like so:

{!$Site.CustomWebAddress}{!$Resource.ResourceName}"

I faced same issue and after spending some time on various blogs and communities, i found solution.

To Access RTA image on site we need to tweak the url which we get while accessing RT field in Apex

URL in Apex: https://c.cs17.content.force.com/servlet/rtaImage?eid=a1Cg0000000JDAi&feoid=00Ng0000000MTcp&refid=0EMg00000007o4U

URL to access RTA image through site :

SiteDomain = XXXXXX.full.cs17.force.com

NewDomain = Replace ".force.com" with ".content.force.com"

Complete RTA image URL = NewDomain + '/servlet/rtaImage?eid=a1Cg0000000JDAi&feoid=00Ng0000000MTcp&refid=0EMg00000007o4U'

i.e

https://XXXXXX.full.cs17.force.com/servlet/rtaImage?eid=a1Cg0000000JDAi&feoid=00Ng0000000MTcp&refid=0EMg00000007o4U

We need to add DomainName along with keyword "content" in between "cs17"(instance) and "force".

Hope this will help.

Thanks Rishi


I get the answer in this official article .

I conclude 3 point :

Reason : Images in the rich text area fields are meant to be "Salesforce internally available only" by default. A user from site is unauthenticated to the image in RTA.

Solution: Step 1 : Make your articles publicly available, which makes them accessible via force.com sites.

Step 2 : You would need to then take the returned img src from your API query call, and substitute the domain there with the public site domain name.

Detail for step can refer in the link above.

Hope this will help.

Thanks