How would I call image from js file on wordpress?

I have peel.js file it has located in root directory (e.g. http://mydomain.com/wordpress/wp-content/themes/anbo/peel.js).

I have called two image from peel.js file, but images not called otherwise not working.

My code:

smartredfox.small_image = 'small.jpg';
smartredfox.big_image = 'large.jpg';

smartredfox.small_path = 'small.swf';
smartredfox.big_path = 'large.swf';

I need help for call the image, otherwise need code for check whether images working or not.

Upvotes: 0

Views: 155

Answers (1)

Shadow Wizard
Shadow Wizard

Reputation: 66389

Your code is just assigning strings, it does not "call" any image.

To actually load the image and show it, have such code:

smartredfox.small_image = 'small.jpg';
$("<img />").attr("src", smartredfox.small_image).appendTo("body");

Live test case.

Upvotes: 1

Related Questions