5

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
  • 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 Oct 9, 2015 at 2:14

1 Answer 1

5

This has been solved with Summer 16 release now .

<aura:component>
<!-- 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'}"/>

You must log in to answer this question.

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