如何将图像上传字段直接添加到自定义书写面板?
1 个回答
- 投票数
@MathSmath提供的代码是正确的.但是,如果您处理许多上传字段,或者要上传多个文件,则必须对其进行大量修改.
此外,它没有利用WordPress媒体库上传文件(这在后台完成了所有肮脏的工作).
我建议您看一下 Meta Box 这样的插件.该插件支持两种上传文件的方式:
它可以帮助您减少编写和维护代码的工作量,尤其是当您要创建多个上传文件时.
免责声明:我是Meta Box的作者.
The code that @MathSmath provided is right. However, if you handle many upload fields, or want to upload multiple files, then you have to modify it a lot.
Besides, it doesn't utilize WordPress media library for uploading files (which does all the dirty work behind the scene).
I'd suggest you take a look at a plugin like Meta Box. The plugin supports both ways to upload files:
input[type="file"]
, which uses a similar code above (see docs) andIt can help you reduce the effort writing and maintaining the code, especially when you want to create multiple uploads.
Disclaimer: I'm the author of Meta Box.
我在wordpress管理员的"页面"下添加了一个新页面,并添加了几个自定义字段.我还希望能够将上传图片字段添加到页面编辑器中-是否可以通过自定义字段来执行此操作?
或者如果我需要这种能力,我需要采取其他方向吗?