0

After moving to Wordpress the images of weather cannot be retrieved even though the JavaScript code runs fine. Here is the code that I am using to retrieve images in custom.js. The code:

$('#weather').openWeather({
    city: 'New York, US',
    placeTarget: '.weather-place',
    iconTarget: '.weather-icon',
    customIcons: 'files/img/icons/weather/'
});

There is something wrong with

'files/img/icons/weather/'

Well firstly when using html the javascript was in files/js/custom.js and the images were in files/img/weather/ it worked but now with wordpress it does'nt work

Your help would be appreciated.

The files folder is in the root directory.

5
  • Could you please provide detailed information? your question is unclear. Commented Mar 13, 2014 at 13:06
  • please describe in detail. it would be appreciated. Commented Mar 13, 2014 at 13:07
  • Have a look at the edited answer Commented Mar 13, 2014 at 13:09
  • That's some nice-looking JavaScript, but it doesn't tell us anything about your environment or what's different than the previous. Commented Mar 13, 2014 at 13:15
  • Alright wait. Let me get you more detail Commented Mar 13, 2014 at 13:16

2 Answers 2

1

If your files directory branches off the root, then try adding a slash before the word "files", like so: customIcons: '/files/img/icons/weather/'

Else, you may need to provide the entire path http://www.mydomain.com/files/...

ALSO, you're not providing a file name /files/img/icons/weather/icon.jpg

Sign up to request clarification or add additional context in comments.

5 Comments

Well the icon.jpg is not necessary because i am using the directory only. /files/img/icons/weather/ does not work
Be sure to look where your directories are. Depending how you set this up, your /files directory could be within WP's directory structure, something like /wp-content/files/img/etc....
Please provide the HTML and methods that are calling the script.
Well firstly when using html the javascript was in files/js/custom.js and the images were in files/img/weather/ it worked like a charm but now with wordpress it doesn't. I'll give more detail if needed
Awesome, glad I could help. FYI, you may be able to get away with using only the portion of the path after the domain. Just be sure to include a starting slash /.
0

If you moved to wordpress, the paths might have changed. Where do you keep your javscript library?

I would use the debug console from your browser to see what happens and which icons your script is trying to get and then modify the path. (press F12 and click on the "network" tab, reload the page and check for 404 errors)

1 Comment

Well firstly when using html the javascript was in files/js/custom.js and the images were in files/img/weather/ it worked like a charm but now with wordpress it doesn't

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.