开发者

Custom Wordpress Plugin - How do I insert content from popup on post editor?

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 开发者_如何学Goinsert 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜