The media_upload_{$tab} WordPress action fires inside limited and specific upload-tab views in the legacy (pre-3.5.0) media popup.
Usage
add_action('media_upload_library', 'your_custom_function');
function your_custom_function() {
// your custom code here
}
Parameters
- There are no parameters for this action.
More information
See WordPress Developer Resources: media_upload_{$tab}
Please note that this action is specific to the legacy media popup (pre-3.5.0) and might not be suitable for newer versions of WordPress.
Examples
Customizing the Media Library tab
To add custom content to the Media Library tab in the legacy media popup:
add_action('media_upload_library', 'customize_media_library_tab');
function customize_media_library_tab() {
echo 'Custom content added to the Media Library tab';
}
Adding a custom tab
To add a new custom tab to the legacy media popup:
add_filter('media_upload_tabs', 'add_custom_media_tab');
function add_custom_media_tab($tabs) {
$tabs['custom_tab'] = 'Custom Tab';
return $tabs;
}
add_action('media_upload_custom_tab', 'custom_tab_content');
function custom_tab_content() {
echo 'Content for Custom Tab';
}
Modifying the library tab behavior
To change the behavior of the Media Library tab in the legacy media popup:
add_action('media_upload_library', 'modify_library_tab_behavior');
function modify_library_tab_behavior() {
// Add custom code to modify the Media Library tab behavior
}
Adding custom JavaScript to a specific tab
To add custom JavaScript to the Media Library tab in the legacy media popup:
add_action('media_upload_library', 'enqueue_custom_js');
function enqueue_custom_js() {
wp_enqueue_script('custom-js', 'path/to/your/custom-js-file.js', array('jquery'), '1.0.0', true);
}
Removing a default tab
To remove the default Media Library tab from the legacy media popup:
add_filter('media_upload_tabs', 'remove_media_library_tab');
function remove_media_library_tab($tabs) {
unset($tabs['library']);
return $tabs;
}