本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
最近给某个客户二次开发时有这样一个需求,客户使用的wp插件wp user frontend pro来实现前端投稿,可是这个插件的pro版在文章正文上传图片时调用的不是系统自带的媒体库上传按钮,而是单独弄的一个上传控件,这对于处女座的人来说无疑是一个不可接受的用户体验。 也有人向插件作者提出这个问题,作者的回复是:(看不懂的用户请自行Google翻译) “As people use the plugin for public post submission, most of them didn’t wanted to expose others uploaded image to other users. Thats why it’s removed and replaced with a plugin native media uploader.”
意思就是说他不想让用户看到所有的媒体文件!!! 难道他不知道wordpress是无比强大吗?不想让用户看到所有的媒体文件,那么可以只让其看到他自己上传的媒体图片就OK了呀。 看看魔扣科技刚写的教程: WordPress 只显示自己上传的媒体图片文件 。 废话说到这,那么如何调用自带的媒体库呢,魔扣科技在这里给出简单粗暴的方法: 文件路径: wp-user-frontend-pro/class/render-form.php 930行左右: - if ( $attr['rich'] == 'yes' ) {
- $editor_settings = array(
- 'textarea_rows' => $attr['rows'],
- 'quicktags' => false,
- 'media_buttons' => true,
- 'editor_class' => $req_class,
- 'textarea_name' => $attr['name']
- );
- wp_editor( $value, $textarea_id, $editor_settings );
- } elseif( $attr['rich'] == 'teeny' ) {
- $editor_settings = array(
- 'textarea_rows' => $attr['rows'],
- 'quicktags' => false,
- 'media_buttons' => true,
- 'teeny' => true,
- 'editor_class' => $req_class,
- 'textarea_name' => $attr['name']
- );
- wp_editor( $value, $textarea_id, $editor_settings );
- } else {
复制代码media_buttons的位置,原本是false,改为true即可。然后你在后台添加表单时,post content的控件里有个 启用图像插入(insert image)选项,不要勾选! 这样修改后,有出现一个边框border的css问题,修复办法: 路径 assets/css/frontend-forms.css 91行左右 - ul.wpuf-form li .wp-editor-wrap {
- /*border: 1px solid #eeeeee;*/
- }
- /*下面的是新加的*/
- ul.wpuf-form li .wp-editor-wrap .wp-editor-container{
- border: 1px solid #eeeeee;
- }
复制代码大功告成!
|