themesplonediazo

How to reference images in a Diazo template?


I'm writing a theme using Diazo using the theme editor of plone.app.theming in Plone 4.3.6. I added a image image.png in the theme folder so it is accessible at http://localhost:8080/mysite/++theme++mytheme-theme/image.png when I'm developing the theme in my computer. I want to refer this image in the template HTML file with <img src="path/image.png">. However it is not clear what to put instead of path. I notice that path cannot be an absolute path because it depends of the site domain. Also, it cannot be a relative path because it depends on the path of each page in the site. May be it would be useful to have an specific keyword to reference the theme folder. For example, <img src="$themeFolder/image.png">. Exists such keyword?


Solution

  • If the HTML file is in your Diazo theme, you can use a relative path from the file, like "images/image.png". Diazo will correctly interpret it.

    You can also use "++theme++mytheme-theme/image.png", as Acquisition would locate the image.