Fórum

Theme Images Path

thumbnail
William Gosse, modificado 9 Anos atrás.

Theme Images Path

Liferay Master Postagens: 533 Data de Entrada: 04/07/10 Postagens Recentes
How do I reference an image in a custom theme's images folder from a theme template file? I was trying something like:
<img src="images/powerbymoasis.png" />
thumbnail
David H Nebinger, modificado 9 Anos atrás.

RE: Theme Images Path

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
It should be dynamically generated using the ThemeDisplay instance.

The ThemeDisplay instance has a method, getPathThemeImages(). In JSP you can do something like <img src="<%= themeDisplay.getPathThemeImages() %>/powerbymoasis.png" />

This makes the code independent of the current theme. Will give you broken images on pages that use a theme that doesn't have the image, but it also means you could have multiple themes that have the image and you can use it without hardcoding.
thumbnail
William Gosse, modificado 9 Anos atrás.

RE: Theme Images Path

Liferay Master Postagens: 533 Data de Entrada: 04/07/10 Postagens Recentes
Thanks, in velocity it looks like this:
<img src="$themeDisplay.getPathThemeImages()/powerbymoasis.png" />
thumbnail
Travis Cory, modificado 9 Anos atrás.

RE: Theme Images Path

Junior Member Postagens: 73 Data de Entrada: 04/06/13 Postagens Recentes
Hello William,

What you posted will work,

<img src="$themeDisplay.getPathThemeImages()/powerbymoasis.png" />

but for future reference you can also use,

<img src="${images_folder}/powerbymoasis.png" />

It works the same but it is a little cleaner.