Foren
Image path in Javascript
Pieter Haro, geändert vor 12 Jahren.
Image path in Javascript
New Member Beiträge: 7 Beitrittsdatum: 19.07.11 Neueste Beiträge
how to specify the image path in Javascript from Liferay
abcd.js
abcd.js
var A_TCALDEF = {
'months' : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
'weekdays' : ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
'yearscroll': true, // show year scroller
'weekstart': 0, // first day of week: 0-Su or 1-Mo
'centyear' : 70, // 2 digit years less than 'centyear' are in 20xx, othewise in 19xx.
[b]'imgpath' : '../img/'[/b] // directory with calendar images
}
Advait Trivedi, geändert vor 12 Jahren.
RE: Image path in Javascript
Junior Member Beiträge: 56 Beitrittsdatum: 30.03.10 Neueste Beiträge
Hi Pieter,
IMHO both the options are OK -
1. an absolute path with theme context "/mytheme/img/myimg.jpg"
2. also a relative path - "../img/myimg.jpg". Note here that path is relative to the JS file.
I am not sure if any one of the above is preferred by Liferay gurus.
Best,
Advait
IMHO both the options are OK -
1. an absolute path with theme context "/mytheme/img/myimg.jpg"
2. also a relative path - "../img/myimg.jpg". Note here that path is relative to the JS file.
I am not sure if any one of the above is preferred by Liferay gurus.
Best,
Advait
Samir Gami, geändert vor 12 Jahren.
RE: Image path in Javascript
Regular Member Beiträge: 162 Beitrittsdatum: 04.02.11 Neueste Beiträge
Pieter,
You can use absolute path with the javaScript, like
"/Test-portlet/img/myImage.jpg" [ /{Portlet-Name}/img/{imageName} ]
You can use absolute path with the javaScript, like
"/Test-portlet/img/myImage.jpg" [ /{Portlet-Name}/img/{imageName} ]
Rupesh Chotai, geändert vor 11 Jahren.
RE: Image path in Javascript
Regular Member Beiträge: 163 Beitrittsdatum: 23.03.11 Neueste Beiträge
Hi Samir,
I was looking for the same issue where I have to get the image path in js file and your suggestion worked.
Thanks.
I was looking for the same issue where I have to get the image path in js file and your suggestion worked.
Thanks.
Amos Fong, geändert vor 12 Jahren.
RE: Image path in Javascript
Liferay Legend Beiträge: 2047 Beitrittsdatum: 07.10.08 Neueste Beiträge
I think you can use the themeDisplay javascript object:
themeDisplay.getPathThemeImages()
Should return something like:
/test-theme/images
themeDisplay.getPathThemeImages()
Should return something like:
/test-theme/images