title: Relative URL to images in another folder accessed inside a JS file
body: <p>I have this Wordpress plugin file structure with "myfolder" as the main folder. There is another subfolder inside this main folder named as "resources". Inside this resources folder contains two subfolders: a) JS  b.) images</p>
  
  <p>Inside images folder I have one image "myimage.png".
  Inside JS file, I have a script named "myscript.js".</p>
  
  <p>I would like to access the image "myimage.png" in images folder inside my javascript file "myscript.js".</p>
  
  <p>I have tried the following but it does not work(does not resolve):</p>
  
  <pre><code>&lt;img src="../images/myimage.png"&gt;
  &lt;img src="images/myimage.png"&gt;
  &lt;img src="resources/images/myimage.png"&gt;
  &lt;img src="../resources/images/myimage.png"&gt;
  &lt;img src="myfolder/resources/images/myimage.png"&gt;
  &lt;img src="../myfolder/resources/images/myimage.png"&gt;
  </code></pre>
  
  <p>Of course the absolute URL path works but I want this application to work with other sites so coding the absolute URL path is not a feasible solution.</p>
  
  <p>I know that Wordpress also has this magic function: </p>
  
  <pre><code>$myicons= plugins_url('resources/images/myimage.png', __FILE__ );
  </code></pre>
  
  <p>But that will work only inside the PHP plugin file and I'm accessing the image inside a JS file. Any ideas how to make this work without rearranging the current file structure? Is there a JS function equivalent of "plugins_url" in Wordpress? Thanks for any tips.</p>