Customizing the WP image editing widget

馋奶兔 提交于 2019-12-22 09:15:39

问题


While editing a post that contains an image, WP attaches a properties inspector icon over the image to allow editing basic properties such as size, alignment, link etc.

I'd like to know how difficult it would be to hack into this dialog screen and add some custom programming to the link area.

I'd like to add a popup menu there that I can access with the click of a button (next to the existing "Link to Image" button.

I'd prefer to hook into this dialog via a file in my theme's folder or via a plug-in. I don't want to alter the wordpress code itself (to allow this to be more portable and theme specific).


回答1:


The edit image popup is a TinyMCE plugin (the rich text editor that Wordpress uses), the files for which are in wp-includes/js/tinymce/plugins/wpeditimage/.

As such you can't simply use the Wordpress plugin API to modify it. You'd need to create your own TinyMCE plugin, probably by duplicating the wpeditimage plugin and adding your extra functionality. You'd also need to create a Wordpress plugin to activate the TinyMCE plugin, see these codex pages for more information on working with TinyMCE plugins in Wordpress:

  • http://codex.wordpress.org/TinyMCE_Custom_Buttons
  • http://codex.wordpress.org/User:Skeltoac/Extending_TinyMCE


来源:https://stackoverflow.com/questions/3114323/customizing-the-wp-image-editing-widget

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!