function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mohammad AnisMohammad Anis 

Unable to Load .png file from Static Resources into .CSS of Aura Component.

I am trying to access the test.png file from my static resource into the .css of a aura component.

Working CSS: background:url('/resource/158765027200/test'); //resource path achieved using {!$Resource.test} in .cmp

Non-Working CSS: background:url('/resource/test');

Issue with the working CSS is that the static resource code is dynamic in nature and hence will vary from one salesforce instance to another, making this code non-ideal for deployment to other instances of salesforce.

Can anyone help me with this issue or any resolution. Thanks!
AbhishekAbhishek (Salesforce Developers) 
Hi Anis,

The below blogs might answer your query,

https://salesforce.stackexchange.com/questions/143630/refer-static-resource-in-css-of-lightning-component

https://developer.salesforce.com/forums/?id=906F0000000DEOCIA4

https://salesforce.stackexchange.com/questions/260010/how-to-add-background-image-to-lightning-component-body-from-static-resource

https://salesforce.stackexchange.com/questions/244266/loading-image-in-static-resource-within-css

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks.