Fórum

Image path in Javascript

Pieter Haro, modificado 12 Anos atrás.

Image path in Javascript

New Member Postagens: 7 Data de Entrada: 19/07/11 Postagens Recentes
how to specify the image path in Javascript from Liferay

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, modificado 12 Anos atrás.

RE: Image path in Javascript

Junior Member Postagens: 56 Data de Entrada: 30/03/10 Postagens Recentes
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
thumbnail
Samir Gami, modificado 12 Anos atrás.

RE: Image path in Javascript

Regular Member Postagens: 162 Data de Entrada: 04/02/11 Postagens Recentes
Pieter,

You can use absolute path with the javaScript, like
"/Test-portlet/img/myImage.jpg" [ /{Portlet-Name}/img/{imageName} ]
Rupesh Chotai, modificado 11 Anos atrás.

RE: Image path in Javascript

Regular Member Postagens: 163 Data de Entrada: 23/03/11 Postagens Recentes
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.
thumbnail
Amos Fong, modificado 12 Anos atrás.

RE: Image path in Javascript

Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
I think you can use the themeDisplay javascript object:

themeDisplay.getPathThemeImages()

Should return something like:
/test-theme/images