I've created my own plugin for WordPress, but it's not completely functional. My goal is to add an additional button to the Post Editor that allows you to insert an image (that you upload from your computer, and automatically gets modified after upload) into the post.
When you click on the button, my popup that I created in my plugin shows up. I go through the upload process and the image is uploaded and modified. Now, how do I insert the image into the post?
This is my code so far:
function insertHeader(imageURL){
text = '<div style="text-align:center;"><img src="'+imageURL+'"/></div>';
tinyMCE.execInstanceCommand('content', 'mceInsertContent', false, text);
}
But obviously it doesn't work. I can't seem to find a good tutorial that shows you how. I've got this far just by looking at other plugins.
try getting idea from the media-upload.php and upload.php of wp-admin