10

I have a Rich Text Area field in which I'm storing images only. When this field is accessed through APEX, an HTML tag <img> is returned with it's properties.

In the controller of my VF page, I am doing a substring to get the URL of the image from the src property which works well when I access the page from within the SF instance /apex/thePage. The result URL that I'm getting is something like this :

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

If I access the same relative path through my site however, I don't have permissions to access that record/object (See image below).

enter image description here

I've got 2 questions here:

1) Where are the images stored in the instance (which object), and can they be accessed from anywhere else but the RTA field itself?

2) Is there any way to reference the URL of the image in a specific format so that the Site can access it (If an object needs permissions for the site profile, which object would that be)?

NOTES :

1) I can't output the RTA field on the page due to the complexity and the structure of the template, I can only reference the URL of the image (Using <apex:image adds other elements around the image).

2) The data model is already built this way, so please don't suggest moving the images to other objects etc.

9

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}"
  • Yes 100% the RTA field/s are visible for the site user's profile... – Boris Bachovski Aug 15 '13 at 1:47
  • Ok, the FLS was set, though I've missed the permissions for the parent object as I had a nested query for the records I was iterating through and getting the images from. – Boris Bachovski Aug 15 '13 at 2:39
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.