[SalesForce] How to add Custom Image to Salesforce Communities

I want to add a custom image to Salesforce Community

This is aleardy done in a test Sandbox the logo is accessible via {Community_url}/s/{imageName}

I am trying to add than in a new Sandbox

So the question is :

how to add an image in Salesforce to be able to access it, in a lightning component like this

<img src="{!'/s/logo.png'}"  alt="logo" />

Thank you

Best Answer

You can simply use the salesforce site class

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_sites.htm

Site.getPathPrefix()

This will give you the prefix of the current site

<img src="{!'/'+v.prefix+'/logo.png'}"  alt="logo" />
Related Topic