Media and other files
Where to put images, fonts, videos, presets and other files your extension ships, and how to use them from HTML, CSS, JavaScript and ExtendScript.
Put files your extension ships in these folders at the project root
(next to afterpresets.json):
assets/ fonts/ icons/ images/ media/They are copied into the build unchanged, at the same place: media/intro.mp4
in the project is media/intro.mp4 inside the installed extension. Other
folders are not shipped. To choose your own list, set it in
afterpresets.json (this replaces the defaults):
"assets": ["media", "presets", "fonts"]These files are not obfuscated or hidden. Anything the buyer installs, they can open. Keep secrets out of them. The whole release must stay under 200 MB.
From HTML and CSS
Section titled “From HTML and CSS”Write paths relative to the file you are in, as usual. They must point into an asset folder; the build rewrites them for the installed extension and fails on a missing file.
<img src="../../../images/logo.png" alt="">.hero { background-image: url(../../../images/hero.jpg); }@font-face { font-family: "Brand"; src: url(../../../fonts/Brand.woff2); }From JavaScript
Section titled “From JavaScript”Use AP.paths; never build paths by hand.
| Call | Returns |
|---|---|
AP.paths.asset("media/intro.mp4") |
Absolute path of a shipped file. Relative path with /; .. and absolute paths throw. |
AP.paths.extension() |
Absolute path of the installed extension folder. |
AP.paths.data() |
A writable folder for your own files. It survives updates. Never write into the extension folder: updates replace it. For settings use AP.storage; see storage.md. |
From ExtendScript (importing into the app)
Section titled “From ExtendScript (importing into the app)”ExtendScript cannot see the panel’s folders by itself. Pass the absolute path from the panel:
// panelctx.host.eval("importClip", [AP.paths.asset("media/intro.mp4")], function (result) { if (result && result.error) { /* show result.error */ }});// After Effects: jsx/aeft/media.jsx (loaded automatically, like every .jsx file in jsx/)function importClip(path) { var file = new File(path); if (!file.exists) return JSON.stringify({ error: "Missing file: " + path }); var item = app.project.importFile(new ImportOptions(file)); return JSON.stringify({ ok: true, name: item.name });}function importClip(path) { var file = new File(path); if (!file.exists) return JSON.stringify({ error: "Missing file: " + path }); // importFiles(paths, suppressUI, targetBin, importAsNumberedStills) var ok = app.project.importFiles([file.fsName], true, app.project.getInsertionBin(), false); return JSON.stringify({ ok: ok === true, name: file.name });}Both files define the same function name: an extension for both apps calls
importClip and each app loads its own version.