Forums de discussion
How to Reference images from a js file
Low Trux, modifié il y a 9 années.
How to Reference images from a js file
Junior Member Publications: 64 Date d'inscription: 06/11/14 Publications récentes
Im using a plugin in js that detects the browser you are using and then popup a window or not, the plugin uses some images that you have to reference from the .js files and im not able to make that work. I have used ${images_folder}/images but didn't work. My plugin .js file is on the _diffs folder and my images on the images folder inside _diffs, this is how the plugin call the images:
// Path where images are located
imagePath:'${images_folder}/images',
As i said before the ${images_folder/images is not doing the trick, it seems like everything i put here call the images from a static url and not a dynamic one, also i recogn that maybe i can't use velocity on a js. Any ideas ?
// Path where images are located
imagePath:'${images_folder}/images',
As i said before the ${images_folder/images is not doing the trick, it seems like everything i put here call the images from a static url and not a dynamic one, also i recogn that maybe i can't use velocity on a js. Any ideas ?
Ahmed bouchriha, modifié il y a 9 années.
RE: How to Reference images from a js file
Junior Member Publications: 55 Date d'inscription: 04/05/12 Publications récentes
Hi,
Use
Best Regards
Use
themeDisplay.getPathImage()
Best Regards
Low Trux, modifié il y a 9 années.
RE: How to Reference images from a js file
Junior Member Publications: 64 Date d'inscription: 06/11/14 Publications récentesAhmed bouchriha:
Hi,
UsethemeDisplay.getPathImage()
Best Regards
That's basically the same thing as using ${images_folder}, the js is not interpreting that the right way. The path that i get using both of those are literally ${images_folder} as a string inside the path.
Ahmed bouchriha, modifié il y a 9 années.
RE: How to Reference images from a js file
Junior Member Publications: 55 Date d'inscription: 04/05/12 Publications récentes
Hi
the ${images_folder} and $themeDisplay.getPathImage() are to be used only on velocity and will not work in js
i think you are confusing between :
and
The first is to be used with velocity only the second is to be used in js and it should return your theme image path.
Hope this help you.
Thanks
the ${images_folder} and $themeDisplay.getPathImage() are to be used only on velocity and will not work in js
i think you are confusing between :
$themeDisplay.getPathImage()
: velocityand
themeDisplay.getPathImage()
; JSThe first is to be used with velocity only the second is to be used in js and it should return your theme image path.
Hope this help you.
Thanks
Low Trux, modifié il y a 9 années.
RE: How to Reference images from a js file
Junior Member Publications: 64 Date d'inscription: 06/11/14 Publications récentesAhmed bouchriha:
Hi
the ${images_folder} and $themeDisplay.getPathImage() are to be used only on velocity and will not work in js
i think you are confusing between :: velocity$themeDisplay.getPathImage()
and; JSthemeDisplay.getPathImage()
The first is to be used with velocity only the second is to be used in js and it should return your theme image path.
Hope this help you.
Thanks
Hello Ahmed, yeah im using
themeDisplay.getPathImage()
and is not working either, as i said before the js is getting the value this way:imagePath: '/images/',
So when i put something like
imagePath: 'themeDisplay.getPathImage()/images/'
the path that im getting is this:localhost:8080/themeDisplay.getPathImage()/images/
You realized the problem right ? the js is getting the text chain as the path but i need to take the real path, i have tried to make a variable something like:
var = themeDisplay.getPathImage(), but is not working either, also when i do this on the console i get "/image" as the path and that's not the entire path to the folder where my images are. Any ideas on how to make this work ?
Just FYI im using this plugin :
http://jreject.turnwheel.com/
Ahmed bouchriha, modifié il y a 9 années.
RE: How to Reference images from a js file
Junior Member Publications: 55 Date d'inscription: 04/05/12 Publications récentes
Hi,
you can use
to add the slash at the end use :
imagePath will contain "http://<your_server>/<your_theme_context>/images/"
for the example you mentioned the right concatenation instruction is
imagePath: themeDisplay.getPathImage()+'/images/' not imagePath: 'themeDisplay.getPathImage()/images/'
any way it seems non useful since even when use the right concatenation this will return '/images//images'.
So try to use themeDisplay.getPathThemeImages() i think this will solve the problem
you can use
themeDisplay.getPathThemeImages()
to add the slash at the end use :
var imagePath = themeDisplay.getPathThemeImages()+'/';
imagePath will contain "http://<your_server>/<your_theme_context>/images/"
for the example you mentioned the right concatenation instruction is
imagePath: themeDisplay.getPathImage()+'/images/' not imagePath: 'themeDisplay.getPathImage()/images/'
any way it seems non useful since even when use the right concatenation this will return '/images//images'.
So try to use themeDisplay.getPathThemeImages() i think this will solve the problem
Low Trux, modifié il y a 8 années.
RE: How to Reference images from a js file
Junior Member Publications: 64 Date d'inscription: 06/11/14 Publications récentesAhmed bouchriha:
Hi,
you can usethemeDisplay.getPathThemeImages()
to add the slash at the end use :var imagePath = themeDisplay.getPathThemeImages()+'/';
imagePath will contain "http://<your_server>/<your_theme_context>/images/"
for the example you mentioned the right concatenation instruction is
imagePath: themeDisplay.getPathImage()+'/images/' not imagePath: 'themeDisplay.getPathImage()/images/'
any way it seems non useful since even when use the right concatenation this will return '/images//images'.
So try to use themeDisplay.getPathThemeImages() i think this will solve the problem
Hey ahmed im REALLY sorry for the late feedback on this, but your advice came in handy at the end so thanks a lot for that. Finally the right way to adress the image folder on my project was : themeDisplay.getPathThemeImages()+'/'. So Yay for that !