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"/>

1 Answer 1


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .