0

I am developing a site into sub dirctory-

sitename.com/subdirectory/

I am including an image link from my theme js file.(js/custom.js)

sitename.com/subdirectory/wp-content/uploads/2014/05/333.png

But when i move the site to main directory. I want the sitename.com/subdirectory/ will automatically converted to http://sitename.com/

is that possible? I try to used

/wp-content/uploads/2014/05/333.png

but its not working.

hocpana
  • 11
  • 1
  • 3
  • try with URL redirecting. For your Reference http://httpd.apache.org/docs/current/rewrite/remapping.html – ArunRaj May 06 '14 at 04:42

2 Answers2

0

you should do js code in your php script before including script file.

var image1= '<?php echo content_url();?>/uploads/2014/05/333.png';

Then use this variable image1 in your js file. This will solve your problem.

Amit Garg
  • 3,867
  • 1
  • 27
  • 37
  • Actually i am using that image for a google map marker. But its not working. var LocsA = [ { lat: 40.71465, lon: -74.03573, title: 'Greene St', html: [ '

    DHS at 70 Greene

    ', '

    70 Greene St Jersey City

    ', '

    NJ 07302

    ' ].join(''), icon:'image1' },
    – hocpana May 06 '14 at 09:12
  • you should use `var LocsA = [ { lat: 40.71465, lon: -74.03573, title: 'Greene St', html: [ '

    DHS at 70 Greene

    ', '

    70 Greene St Jersey City

    ', '

    NJ 07302

    ' ].join(''), icon:image1 },` image1 without quotes.
    – Amit Garg May 07 '14 at 03:54
  • yes, i used icon:image1 but it's not working. any idea? – hocpana May 08 '14 at 06:36
  • Can you see `var image1= '/uploads/2014/05/333.png';` in your source code? is it before your included file? – Amit Garg May 08 '14 at 07:28
0

You can get the current URL by javascript from this Get current URL in web browser

Then check if current URL in subdirectory or not then you can decide what link should to pass to your image link in javascript file

Community
  • 1
  • 1