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...
April 3rd 20 at 17:25
1 answer
April 3rd 20 at 17:27
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?
Take pictures in a separate folder

I would like to plug even. Took his folder was moved to another project and it is already running.
what is the point to constantly change the path of the plugin?

Of course this task is not necessary, but suddenly, in another project, you will need to put in a different folder, then you will need to edit the path. There is another option. Use the styles and blocks of div, not an img tag with the path to the picture. But we have a lot to redo... well while I think. Perhaps it is easier to specify all the same path relative to site root and not to bother - baby commented on April 3rd 20 at 17:30
@baby, from the root. And make a configuration file where you register the path) so as for me it will be easier then), although the identity XS))) actually mine garbage suffer) - George56 commented on April 3rd 20 at 17:33
@George56, I just said, maybe there's a possibility, but I don't know about her. Now just prescribed path relative to the root and calmed down ))) - baby commented on April 3rd 20 at 17:36
@baby, well, everything. In future projects do also. And not have them. Logically the same?. But if you plan to transfer to other plugin developers which can on another to place it, as already suggested, in the configs everything is changing in several files. It will be easier to change the structure - lukas_Da commented on April 3rd 20 at 17:39

Find more questions by tags jQuery