Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've been searching high and low for an answer.

I simply want to remove the Alternate Text, Caption, Description and Link URL-fields from the uploader and gallery view.

I seem that every thing else than this Media-thingy can be removed.

Thanx for helping out:)

share|improve this question
    
This Trac comment makes it clear that the solutions below will no longer work. Does anyone have an updated anser to this question? core.trac.wordpress.org/ticket/22664#comment:7 –  infamouse Apr 3 '13 at 19:38
add comment

3 Answers

up vote 4 down vote accepted

You can do this via a filter. Add the following to functions.php. You can also add your own fields this way...

// edit fields in media upload area
add_filter('attachment_fields_to_edit', 'remove_media_upload_fields', 10000, 2);
function remove_media_upload_fields( $form_fields, $post ) {

    // remove unnecessary fields
    unset( $form_fields['image-size'] );
    unset( $form_fields['post_excerpt'] );
    unset( $form_fields['post_content'] );
    unset( $form_fields['url'] );
    unset( $form_fields['image_url'] );
    unset( $form_fields['align'] );

    return $form_fields;
}

The example above strips out more than you need to but if you do a print_r() on the $form_fields variable you'll see what's available to add/remove.

share|improve this answer
    
thanks! Works like a charm :) –  Jonas Thomsen Mar 14 '12 at 19:38
    
Doesn't appear to work any more. $form_fields is empty for this filter. –  infamouse Apr 3 '13 at 19:11
add comment

The sanchothefat's Answer is correct, really Works like a charm.

Just for increase his answer, you can use unset( $form_fields['image_alt'] ); to remove the Alternate Text.

Thanks for Answering sanchothefat, it Helped me.

share|improve this answer
add comment

Unfortunately it looks like this changed quite a bit in WP3.5 when they upgraded the media library. That filter's $form_fields parameter doesn't contain the defaults any more. The only solution I've found so far is to forcibly remove the markup from the view using buffering:

This is extremely fragile - any change to the WordPress core might break this

function wpse45562_remove_media_fields( $buffer ) {
    // remove the 'caption' block
    $buffer = preg_replace( '~<p>\s*<label\s*for="attachment_caption">.*?</p>~ims', '', $buffer );
    // remove the 'alt text' block
    $buffer = preg_replace( '~<p>\s*<label\s*for="attachment_alt">.*?</p>~ims', '', $buffer );

    // remove the 'description' box (and label separately)
    $buffer = preg_replace( '~<div\s*id="wp-attachment_content-editor.*?</div>~ims', '',   $buffer );
    $buffer = preg_replace( '~<label\s*for="content">.*?</label>~ims', '', $buffer );

    return $buffer;
}

function wpse45562_media_strip_buffer_start() { ob_start("wpse45562_remove_media_fields");  }
function wpse45562_media_strip_buffer_end() { ob_end_flush(); }

add_action('admin_head', 'wpse45562_media_strip_buffer_start', 10, 1);
add_action('admin_footer', 'wpse45562_media_strip_buffer_end', 10, 1);
share|improve this answer
    
I think there a some filters in the js backbone templates where the fields get added we might be able to co-opt. It certainly isn't straightforward any more though :( –  sanchothefat Apr 4 '13 at 9:27
    
I agree. For now I've opened a ticket over on Trac. If they're going to make it the same as any other post it should respond to remove_post_type_support(), at least. –  infamouse Apr 4 '13 at 21:43
    
Thanks for the update ! :) –  Jonas Thomsen Apr 17 '13 at 14:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.