Add “Update image attributes” Bulk Action To Any Post Type

Image Attributes Pro 3.0 ships with a Bulk action “Update image attributes“. This is added to the Bulk actions in WordPress Media Library, Posts, Pages and WooCommerce Products by default.

You can add this bulk action to other post types simply by adding the following code to the functions.php of your active theme.

Remember to replace {$this->screen->id} with the screen ID of the Edit post type screen before doing so.

 * Add Image Attributes Pro Bulk action "Update image attributes" to a post type. 
 * Remember to replace {$this->screen->id} with the screen ID of the Edit post type screen.
 * @link
add_filter( 'bulk_actions-{$this->screen->id}', 'iaffpro_add_bulk_action_update_image_attributes_to_posts' );
add_filter( 'handle_bulk_actions-{$this->screen->id}', 'iaffpro_handle_posts_bulk_action_update_image_attributes', 10, 3 );

How To Find {$this->screen->id}

  • To find the screen ID of the Edit screen of your post type, first navigate to the post type Edit page in WordPress admin.
  • Then check source code of the page and you will see something like below. This example is from the Products list screen of WooCommerce products.
Bulk Action Update Image Attributes Woocommerce Products
Finding Screen ID In WordPress Admin
pagenow is the screen ID
  • To check the source code, simply right click anywhere and select View source code or similar option in most browsers.
  • Look for pagenow = 'screen-id'.
  • In this example, edit-product is the {$this->screen->id}
  • In the code snippet, bulk_actions-{$this->screen->id} will have to be bulk_actions-edit-product.

Example Usage

Here is an example where Bulk Actions were added to the Classified Listing plugin. edit-rtcl_listing is the screen ID of the custom post type created by the plugin.

 * Add Image Attributes Pro features to Classified Listing.
 * @link
 * @link
add_filter( 'bulk_actions-edit-rtcl_listing', 'iaffpro_add_bulk_action_update_image_attributes_to_posts' );
add_filter( 'handle_bulk_actions-edit-rtcl_listing', 'iaffpro_handle_posts_bulk_action_update_image_attributes', 10, 3 );
add_action( 'add_meta_boxes_rtcl_listing', 'iaffpro_add_meta_box_posts_pages' );

As a bonus, the above snippet also adds the Image Attributes Pro meta box to the edit screen of the post type by hooking on to add_meta_boxes_rtcl_listing action hook.

Please feel free to reach out if you have further questions.

Was this article helpful?
Yes, thanks! 👍Not really 👎