掲示板

Inserting Image in velocity HTML code

thumbnail
8年前 に John Voltaire Maximo によって更新されました。

Inserting Image in velocity HTML code

Regular Member 投稿: 106 参加年月日: 15/06/19 最新の投稿
Hi guys,

I'm creating a theme template using velocity, however I can't seem to get the image that I wanted.. here's my code and it's in HTML I code under portal_normal.vm

<div>
<img style="height: 160px;" src="/images/grp__NM__gcg_banner.png" border="0" width="100%">
</div>

velocity accepts html syntax,, but this code doesn't work,, I get my image under _diffs/images folder,,, I tried doing the following:
<img style="height: 160px;" src="../images/grp__NM__gcg_banner.png" border="0" width="100%">
<img style="height: 160px;" src="./images/grp__NM__gcg_banner.png" border="0" width="100%">
<img style="height: 160px;" src="_diffs/images/grp__NM__gcg_banner.png" border="0" width="100%">
<img style="height: 160px;" src="fullpathhere" border="0" width="100%">
but all of these aren't working

is there an alternative way or maybe my code is wrong?? suggestions please, thanks
thumbnail
8年前 に David H Nebinger によって更新されました。

RE: Inserting Image in velocity HTML code

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
Remember that when using an absolute path the path must point to an absolute image.

So "/images/grp..." means that for a tomcat deploy you would have the "webapps/ROOT/images/grp..." file which is not very likely.

Instead I think you're actually trying to get a dynamic path to the images folder relative to your theme. Instead of using a fixed value like this, use the following:

src="$images_folder/grp_..."

Per the values you can find here, this will expand to the appropriate place and you just have to know where in images your file actually is.
thumbnail
8年前 に John Voltaire Maximo によって更新されました。

RE: Inserting Image in velocity HTML code

Regular Member 投稿: 106 参加年月日: 15/06/19 最新の投稿
I solved it using $images_folder...
it appears that liferay has these theme variables that I can use to get my resources..

for this particular problem I can either use
<div>
<img style="height: 160px;" src="$images_folder/grp__NM__gcg_banner.png" border="0" width="100%">
</div>

or

<div>
<img style="height: 160px;" src="$<img src="$themeDisplay.getPathThemeImages()//grp__NM__gcg_banner.png" border="0" width="100%">
</div>

Thank you emoticon

PS. I used these links for references
http://javaeasyforu.blogspot.in/2014/02/how-to-include-css-or-js-or-image-file.html
http://content.liferay.com/4.3/misc/theme-api-4.3.0.html
thumbnail
8年前 に David H Nebinger によって更新されました。

RE: Inserting Image in velocity HTML code

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
John Voltaire Maximo:
PS. I used these links for references
http://javaeasyforu.blogspot.in/2014/02/how-to-include-css-or-js-or-image-file.html


Ugh. External blogs like this covered with ads and other crap, I don't really trust them. That being said, this one doesn't seem to be that bad but it is a year and a half old. But it is certainly better than:

http://content.liferay.com/4.3/misc/theme-api-4.3.0.html


See that version on there, Liferay 4.3? Do you think that you should really be using that as a reference these days? I mean, this is probably the one thing from 4.3 that hasn't changed, but little else still applies...
thumbnail
8年前 に John Voltaire Maximo によって更新されました。

RE: Inserting Image in velocity HTML code

Regular Member 投稿: 106 参加年月日: 15/06/19 最新の投稿
hahaha, got it,, I'll always look at the wiki first.. or ask here instead haha