Foren
Theme Images Path
William Gosse, geändert vor 9 Jahren.
Theme Images Path
Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
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" />
<img src="images/powerbymoasis.png" />
David H Nebinger, geändert vor 9 Jahren.
RE: Theme Images Path
Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
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.
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.
William Gosse, geändert vor 9 Jahren.
RE: Theme Images Path
Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
Thanks, in velocity it looks like this:
<img src="$themeDisplay.getPathThemeImages()/powerbymoasis.png" />
<img src="$themeDisplay.getPathThemeImages()/powerbymoasis.png" />
Travis Cory, geändert vor 9 Jahren.
RE: Theme Images Path
Junior Member Beiträge: 73 Beitrittsdatum: 04.06.13 Neueste Beiträge
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.
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.