2013-01-09 41 views
4

新的媒體管理器看起來非常棒,非常好,但是,與之前的版本一樣,它在附件詳細信息中有幾個字段,我想避免這些字段用於使用此代碼:從New Wordpress媒體管理器的附件詳細信息中刪除字段

add_filter('attachment_fields_to_edit', 'remove_media_upload_fields', 10000, 2); 
function remove_media_upload_fields($form_fields, $post) { 

    unset($form_fields['image_alt']); 
    unset($form_fields['post_content']); 
    unset($form_fields['post_excerpt']); 
    unset($form_fields['url']); 
    unset($form_fields['image_url']); 
    unset($form_fields['align']); 
    unset($form_fields['image-size']); 

    return $form_fields; 
} 

但似乎它不適用於新版本。

我該如何刪除新媒體管理器中的這些字段?

回答

0

我也遇到了這個問題。有幾個解決方法,但我發現以下效果最好......當您從編輯器頁面(metabox鏈接)中單擊「添加精選圖像」時,「插入到後期」的選項以及您提到的所有選項媒體經理失蹤了。這對我來說非常完美,因爲我想刪除用戶插入圖片到帖子中的選項。如果這是你以後,把這個代碼在主題functions.php文件...

/** 
* Add if you want to remove image edit option from Media Manager. 
*/ 
add_action('admin_footer-post-new.php', 'wpse_76214_script'); 
add_action('admin_footer-post.php', 'wpse_76214_script'); 
function wpse_76214_script() { 
?> 
<script type="text/javascript"> 
jQuery(document).ready(function($) { 
    $('li.attachment').live('click', function(event) { 
     $('.media-sidebar a.edit-attachment').remove(); // remove edit image link 
    }); 
}); 
</script> 
<?php 
} 

/** 
* Removes "Add Media" Button from the editor. 
*/ 
function z_remove_media_controls() { 
remove_action('media_buttons', 'media_buttons'); 
} 
add_action('admin_head','z_remove_media_controls'); 

/** 
* Takes over the "Featured Image" meta box and allows you to change its options. 
*/ 
add_action('do_meta_boxes', 'change_image_box'); 
function change_image_box() 
{ 
remove_meta_box('postimagediv', 'post', 'side'); 
remove_meta_box('postimagediv', 'page', 'side'); 
// if you have other post types, remove the meta box from them as well 
// remove_meta_box('postimagediv', 'your-post-type', 'side'); 
add_meta_box('postimagediv', __('Add Images'), 'post_thumbnail_meta_box', 'post', 'side'); 
add_meta_box('postimagediv', __('Add Images'), 'post_thumbnail_meta_box', 'page', 'side'); 
} 

/** 
* Renames Feature Image Link that appears inside meta box. 
*/ 
add_action('admin_head-post-new.php',change_thumbnail_html); 
add_action('admin_head-post.php',change_thumbnail_html); 
function change_thumbnail_html($content) { 
    add_filter('admin_post_thumbnail_html',do_thumb); 
} 
function do_thumb($content){ 
return str_replace(__('Set featured image'), __('Add Images and Set Featured'),$content); 
} 

現在,用戶只能通過單擊元框中的鏈接,這是添加圖片現在名爲「添加圖片」。此外,元框中的鏈接已更改以避免混淆。希望這可以幫助!

相關問題