How to modify the attachment info text on gallery tab or media page?

Add this to functions.php file. function image_attachment_field($form_fields, $post) { if( substr($post->post_mime_type, 0, 5) == ‘image’ ){ $user = new WP_User( $post->post_author ); $form_fields[“author”][“input”] = “html”; $form_fields[“author”][“html”] = ‘<p><strong>Author:</strong> ‘.$user->display_name.'</p>’; $form_fields[“license”][“input”] = “html”; $form_fields[“license”][“html”] = ‘<p><strong>License:</strong> GPL</p>’; $form_fields[“source”][“input”] = “html”; $form_fields[“source”][“html”] = ‘<p><strong>Source:</strong> BNS</p>’; } return $form_fields; } add_filter(“attachment_fields_to_edit”, “image_attachment_field”, null, 2); This will ONLY add … Read more

Conditional tag to determine if the user is viewing the Add Media (after clicking Add media button)

There are multiple actions available. Demo: add_action( ‘upload_ui_over_quota’, ‘wpse_78085_callback’ ); add_action( ‘pre-upload-ui’, ‘wpse_78085_callback’ ); add_action( ‘pre-plupload-upload-ui’, ‘wpse_78085_callback’ ); add_action( ‘post-plupload-upload-ui’, ‘wpse_78085_callback’ ); add_action( ‘post-upload-ui’, ‘wpse_78085_callback’ ); function wpse_78085_callback() { # see wp-includes/media-template.php print ‘<pre>’ . current_filter() . ‘</pre>’; } Result:

Adding Alt Tag Column to Media Library List

Here’s the code – function wpse_media_extra_column( $cols ) { $cols[“alt”] = “ALT”; return $cols; } function wpse_media_extra_column_value( $column_name, $id ) { if( $column_name == ‘alt’ ) echo get_post_meta( $id, ‘_wp_attachment_image_alt’, true); } add_filter( ‘manage_media_columns’, ‘wpse_media_extra_column’ ); add_action( ‘manage_media_custom_column’, ‘wpse_media_extra_column_value’, 10, 2 ); It could go to functions.php file or into your plugin.

Media library disallows spammy filenames?

No, WordPress doesn’t do this. You can check by looking at the source code. What’s probably happening is the image is too large for WordPress to resize properly, or it’s been corrupted. Keep in mind that there are breweries with websites powered by WordPress, and you can buy beer themes on markets

Reorder attachements in the media library

Attachments in Media Library are obtained using WP_Query, so you can modify that query with pre_get_posts action. By default they are sorted DESC by post_date. So the easiest way to fix your code would be to change so the new modified attachment has the same post_date set as the original one.

Media Library, hook on delete user action

A more appropriate hook may be delete_attachment($post_id). You may also need to hook edit_attachment. Note that the post_id is that of the attachment type post, not the page/blog post to which the media is attached (if any). In case you want to know when media is added, hook add_attachment($post_id). Note that add_attachment is called before … Read more