Loading

Images Saved as Static Resources Don't Display on the Experience Cloud Site

Publiceringsdatum: Oct 13, 2022
Beskrivning
If you create a static resource that stores an image, you want to use this image on a site page. Let's assume the URL of your static resource is as follows:

https://naX.salesforce.com/resource/13237000/PortalLogo

For example, if you wanted this component to show as a home page component on your site home page, you would create an HTML component that looks like this:

<img src="https://naX.salesforce.com/resource/13237000/PortalLogo">

When logging in as a site user, you notice that the image link is broken.
Lösning

The reason this happens is that your site has a different domain than your Salesforce instance. For example:

Your instance: na12.salesforce.com
Your site: mysite.com/support

For these images to be available, the home page component must use the relative URL, including the name of your Experience Cloud site page. For example

<img src="/support/resource/13237000/PortalLogo"> - Replace "/support/" with the name of your site page. 

Another workaround is to use upload the image to the Documents tab in Salesforce Classic, and enable the "Externally Available Image" setting. This way you can use the URL of this image on your home page component and it’s accessible to anyone, regardless of the domain. Note: you do not need to change the URL of the document, since it's stored in our server and is accessible to anyone. The Documents tab isn’t supported in Lightning Experience so you must access this via Salesforce Classic. 

When used in a Visualforce page, use the URLFOR function. 


 
Knowledge-artikelnummer

000387235

 
Laddar
Salesforce Help | Article