Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#65204 assigned defect (bug)

Custom Bulk Actions missing from Grid View

Reported by: takshil Owned by: takshil
Priority: normal Milestone: Awaiting Review
Component: Media Version:
Severity: major Keywords: has-patch
Cc: Focuses: ui, javascript, administration

Description

The Media Library list view allows plugins to register custom bulk actions via the bulk_actions-upload and handle_bulk_actions-upload PHP filters. However, the grid view (wp-admin/upload.php?mode=grid) does not reflect those bulk actions. The toolbar in bulk select mode is hardcoded to only show the Delete button.

This means plugins which add bulk actions like the AI Experiments plugin's(e.g. "Generate Alt Text") to the Media page, will simply not show up on the grid view.

Attachments (2)

Screenshot 2026-05-08 at 4.42.59 AM.png​ (74.3 KB ) - added by takshil 5 months ago.
Normal Bulk actions available in the Bulk actions selector in the legacy List View
589073656-12f2c878-02f6-4860-885f-8f04b9795122.png​ (263.0 KB ) - added by takshil 5 months ago.
Custom Bulk Action missing from the Grid View Bulk actions

Download all attachments as: .zip

Change History (6)

#1 @takshil
5 months ago

Sample plugin to test this issue:

<?php
/**
 * Plugin Name: Test Media Grid Bulk Action
 * Description: Test plugin for the media grid bulk actions bridge. Registers a
 *              single "Generate Alt Text" bulk action via PHP filters. With the
 *              core patch, this automatically appears in both list and grid views.
 * Version: 1.0.0
 * Author: Test
 */

if ( ! defined( 'ABSPATH' ) ) {
        exit;
}

function test_mgba_add_list_view_bulk_action( $actions ) {
        $actions['generate_alt_text'] = __( 'Generate Alt Text' );
        return $actions;
}
add_filter( 'bulk_actions-upload', 'test_mgba_add_list_view_bulk_action' );


function test_mgba_handle_list_view_bulk_action( $redirect_url, $action, $post_ids ) {
        if ( 'generate_alt_text' !== $action ) {
                return $redirect_url;
        }

        // In a real plugin, this would process the attachments.
        $redirect_url = add_query_arg( 'generate_alt_text_count', count( $post_ids ), $redirect_url );

        return $redirect_url;
}
add_filter( 'handle_bulk_actions-upload', 'test_mgba_handle_list_view_bulk_action', 10, 3 );

@takshil
5 months ago

Normal Bulk actions available in the Bulk actions selector in the legacy List View

@takshil
5 months ago

Custom Bulk Action missing from the Grid View Bulk actions

This ticket was mentioned in ​PR #11765 on ​WordPress/wordpress-develop by ​@takshil.


5 months ago
#2

  • Keywords has-patch added

Plugins can add bulk actions to the Media Library list view via bulk_actions-upload and handle_bulk_actions-upload, but the grid view has no equivalent, its toolbar is hardcoded to only show Delete. This patch bridges the existing PHP filters into the grid view so plugins get both views for free with zero code changes.

Trac ticket: https://core.trac.wordpress.org/ticket/65204

Before After

| https://github.com/user-attachments/assets/e83cfd68-c0bb-48b3-afd7-0397e6f5f32d | https://github.com/user-attachments/assets/5179e2b7-0628-43bb-aa41-71488d2a76b4 |

## Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.6
Used for: Used for initial discovery of the issue and finding relevant pieces of code, discussing approach and implementing finer details. Last code was reviewed, iterated on, and validated by me.

#3 @audrasjb
5 months ago

Removing trunk version as this is not going to be shipped with WP 7.0 but in the next releases.

#4 @audrasjb
5 months ago

  • Version trunk
Note: See TracTickets for help on using tickets.