How to specify the path to the image file in. js in the directory?
Good afternoon, dear programmers. Started on your online to improve jquery plugins. We want to place them in a shared folder and everyone inside it to put in your folder. And faced with the problem.
For example, I as a user can find on the website page site.ru/news/1/
And I have it connected plugin /plagins/uploader/jqueryMU.js
This plugin uses the preview of the type of downloadable file, icon music, icon video, etc. icons are placed in the same directory where the script itself, in the images folder.
If I specify the path to the image /images/img.jpg the path is specified relative to the root of the website, if show the way ./images/img.jpg the path is specified relative to the path where I am on the website. How to specify the path relative to the script? You can specify the path again of course relative to site root like /plagins/uploader/images, but this option is not very good, because if you change the plugin location, then the path rule will need in the js file. To pass the path to the plugin in the plugin? Also the extra settings...
The flea. Regarding the script without crutches in any way, should specify the path from the root. Take pictures in a separate folder, not scripts and then they will not depend on the position of the script.
You can try to change the images to SVG, lousy them in JS, or to make the Assembly of the bundle for the site.
In the end: what is the point to constantly change the path of the plugin?