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.

As the title says: Is there a hook for the popup window which shows up when you click on the edit button on an image in a post?

share|improve this question
    
It might be better to upgrade to 3.5 before asking media UI questions. This version will be released in some days and massively change everything. –  kaiser Dec 3 '12 at 14:53
    
Thank you for the comment but unfortunately I need that now. But I'll have a look at 3.5 –  Stephan S. Dec 3 '12 at 14:55
    
Then just update to 3.5 RC1. Will simplify your life a lot. –  kaiser Dec 3 '12 at 14:57
add comment

1 Answer

add_filter( 'attachment_fields_to_edit', 'attachment_fields_to_edit', null, 2 );
add_filter( 'attachment_fields_to_save', 'attachment_fields_to_save', null, 2 );

function attachment_fields_to_edit( $form_fields, $post ) {
    $form_fields['my_attachment_field'] = array(
        'label' => 'My Label',
        'input' => 'text',
        'value' => get_post_meta( $post->ID, '_my_attachment_field', true )
    );

    return $form_fields;
}

function attachment_fields_to_save( $post, $attachment ) {
    if ( ! empty( $attachment['my_attachment_field'] ) )
        update_post_meta( $post['ID'], '_my_attachment_field', $attachment['my_attachment_field'] );
    else
        delete_post_meta( $post['ID'], '_my_attachment_field' );

    return $post;
}
share|improve this answer
    
Thank you but that was not what I was looking for, I was looking for a hook to edit the content/add form fields when I click on edit image in a post and not in the media library - see my opening post. –  Stephan S. Dec 4 '12 at 13:50
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.