This feature is currently in Early Availability (EA) status. For more information, see our product lifecycle phases.
Add static assets
If your extension uses static assets such as images, videos, or CSS files, you can add them to your extension and reference them in your code. Follow these steps:
Step 1: Add your static assets
Put your static assets in the static/assets folder of your extension. You can add images, videos, CSS files, and other static files.
.
└── src
└── static
└── assets
├── myimage.png
├── styles.css
└── video.mp4
Step 2: Reference your static assets in code
Use window.get_extension_assets in your extension code to get the URL of an asset. Pass the asset filename as the argument.
For example, for an image myimage.png in static/assets:
const App = () => {
const imageUrl = window.get_extension_assets('myimage.png');
return (
<div>
<img alt="test img" src={imageUrl}/>
</div>
);
};
The function returns the URL of the image, which you can use in your extension.
After you add assets to static/assets and reference them with window.get_extension_assets, they are available in your extension.
Was this page helpful?
Tell us more…
Help us improve our content. Responses are anonymous.
Thanks
We appreciate your feedback!