Upload an image to WordPress using jQuery

I am developing a template page for WordPress, I need to upload an image, when I click the button, the path is namesite.com/wordpress/test , and I need to upload an image

 $("<img src='wp-content/themes/twentytwelve/images/loader.gif' class='loader' />").appendTo("#contact"); 

The problem is that the image is not running in wordpress/wp-content/themes/twentytwelve/images/loader.gif , but in wordpress/test/wp-content/themes/twentytwelve/images/loader.gif , so I have error. How can i do

+6
source share
1 answer

Prepare img src with '/' to start from the root. Example:

 $("<img src='/wordpress/wp-content/themes/twentytwelve/images/loader.gif' class='loader' />").appendTo("#contact"); 
+5
source

All Articles