Newer Version Available

This content describes an older version of this product. View Latest

Use Images in an LWC Offline-Enabled Component

Lightning Web Components supports multiple ways of referencing graphics assets in a component. Not all of these methods work when the component runs offline. LWC Offline supports several methods of referencing images in your offline-ready Lightning web components.

The standard methods for referencing images (and other binary assets) in an LWC are:

  • Images uploaded as Files, using the VersionDataUrl field of the latest ContentVersion related to a particular ContentDocument record.
  • Content Assets, using the @salesforce/contentAssetUrl module.
  • Static Resources, using the @salesforce/resourceUrl module.

For LWCs with images intended to be used offline, we recommend the first two options. Static resources support offline images, but with limitations.

Support for offline images requires that both your Salesforce org and your mobile app are updated to the Summer ’23 release (API 58.0) or later.

Note