I'm trying to include an image that I loaded as a static resource in a Lightning component. The image doesn't show up if I don't include my namespace. For example, this won't work:

<img src="/resource/FFPsa" />

However, if I include my namespace, it will:

<img src="/resource/abehrmandev210__FFPsa" />

How can I use the image without using my namespace?

For those not doing managed development, wouldn't this also cause issues with static resource caching? URLFOR in visualforce adds a cache buster to the path to prevent stale data, but it seems lightning has so such facility. Is this right?

  • 1
    From the docs ,there is no official way to do this yet .For managed package you will need to include a namespace for your component – Mohith Shrivastava Oct 9 '15 at 2:14

This has been solved with Summer 16 release now .

<!-- Stand-alone static resources -->
<img src="{!$Resource.generic_profile_svg}"/>
<img src="{!$Resource.yourNamespace__generic_profile_svg}"/>

<!-- Asset from an archive static resource -->
<img src="{!$Resource.SLDSv1 + '/assets/images/avatar1.jpg'}"/>
<img src="{!$Resource.yourNamespace__SLDSv1 + '/assets/images/avatar1.jpg'}"/>

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.