3

I am trying to include an image from static resources in a Lightning component. The image is displaying correctly when I use that component in an App. But does not display anything when I use the same component in communities.

The code i am using is :

<img src="/resource/Icon_one" height="30" width="30"/>
7

Your community will have a URL prefix and you will need to add that prefix as well

<img src="/urlpathprefix /resource/Icon_one" height="30" width="30"/>

You can return this prefix using Netwrok Object record

String urlpathprefix = [Select UrlPathPrefix from Network where Id =:Network.getNetworkId()].UrlPathPrefix 

Try prepending 'sfsites/c/' to you url. No need to query for the base url

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.