Show static images in custom theme
Solved
Technical Support
-
Hey mates,
I'm trying to show a static image in my custom theme.
The custom theme works fine but the images don't get displayed.The folder structure looks like this:
theme-root
--static
----images
------image.png
--templates
----folder
------file.tplAnd the line of code where I try to implement looks like this:
<img src="/theme-root/static/images/image.png">I tried several things but nothing worked for me.
-
@daniel-kück what does the plugin.json in your theme look like? You'll probably need to add a
staticDirs
like this:"staticDirs": { "images": "static/images" },
And then access the image like this:
<img src="{config.relative_path}/plugins/nodebb-theme-yourtheme/images/image.png">
https://github.com/NodeBB/nodebb-plugin-emoji/blob/master/plugin.json#L13
https://github.com/NodeBB/nodebb-plugin-emoji/blob/master/public/lib/emoji.ts#L4 -
Nice it worked, thanks a lot!
Copyright © 2024 NodeBB | Contributors