loadImage issue

I have a trivial problem. I can’t seem to load an image file, which is in the same directory as the html code here https://editor.p5js.org/ylh888/sketches/wNPt1-pbY

Running on my local browser, it shows the same “Loading …” message as in the linked sketch above, but of course I do have the file in the directory. What seems to be the problem? I’m using OSX with Safari and Chrome. Is there is a security setting that I need to reset?

1 Like

Your “sketch.js” file there got HTML tags in it, such as <html>, <script> & <body>. :warning:

Vanilla JS syntax doesn’t support those kind of tags. Those should go into “.html” files instead. :no_entry:

Here’s a sketch w/ “index.html” + “sketch.js” files, and 2 images inside its subfolder “assets/”: :sunglasses:

2 Likes

Thanks.

My ‘sketch’ was actually an index.html code with javascript included.

In any event, I replicated your code and still get “Loading …”. I am guessing it may be an ‘environment’ issue of some sort.

If you wish, you can delete the “sketch.js” file and keep “index.html” only w/ your whole code in it.

However, for organization purposes, it’s better to separate the HTML code from the JS 1s.

1 Like

OSX Safari defaults to blocking uploading of local files. The solution is to go into Develop tab and check Disable Local File Restrictions.

2 Likes