Saving attachment custom fields

Got it: add_filter(“attachment_fields_to_edit”, “my_image_attachment_fields_to_edit”, null, 2); function my_image_attachment_fields_to_edit($form_fields, $post) { $form_fields[“OwnersHeading”][“tr”] = ” <tr> <td colspan=’2′ style=”font-size:16px;padding-left:15px”>Tag Users:</td> </tr>”; // get list of users $wp_user_query = new WP_User_Query( array( ‘orderby’ => ‘display_name’ ) ); $authors = $wp_user_query->get_results(); if (!empty($authors)) { foreach ($authors as $author) { $belongs_to_value = (bool)get_post_meta( $post->ID, “_owner_$author->ID”, true ); // create the … Read more

How to set default value for ‘Alt text’ on image upload dialog?

Ok, the answer will not be short At first, You can’t change the alt attribute using attachment_fields_to_edit, because you can’t modify default fields. To see how this works can be in the source code of get_compat_media_markup. With attachment_fields_to_edit you can add only additional input fields. Example: /** * Add custom field for Images * * … Read more