Remove fields from attachment details in new Wordpress Media Manager

The new Media Manager looks amazing, very nice, however, as in the previous version, it has several fields in the Attachment details that I would like to avoid, I used this code:

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; } 

But it does not seem to work in the new version.

How can I delete these fields in New Media Manager?

+4
source share
1 answer

I had problems with this. There are several workarounds, but I found that the following works best ... when you click "Add Favorite Image" from the editor page (link to metabolism), the options to "paste into a message" and all the options that you mention are missing from the media manager. This was ideal for me, as I wanted to remove the ability for users to embed images in messages. If this is what you need, put this code in your theme functions.php file ...

 /** * 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); } 

Now users can add images by clicking on the link in the meta window, which is now called "Add Images". In addition, the link in the meta-field has been changed to avoid confusion. Hope this helps!

0
source

All Articles