Using WordPress ‘media_upload_{$type}’ PHP action

The media_upload_{$type} WordPress action is used to trigger custom code inside specific upload-type views in the legacy (pre-3.5.0) media popup based on the current tab.

Usage

add_action('media_upload_audio', 'my_custom_audio_upload_function');
function my_custom_audio_upload_function() {
    // your custom code here
}

Parameters

  • None

More information

See WordPress Developer Resources: media_upload_{$type}

Examples

Adding custom functionality for audio uploads

This example adds custom functionality for audio uploads in the legacy media popup.

add_action('media_upload_audio', 'my_custom_audio_upload_function');
function my_custom_audio_upload_function() {
    // Add custom functionality for audio uploads
}

Adding custom functionality for file uploads

This example adds custom functionality for file uploads in the legacy media popup.

add_action('media_upload_file', 'my_custom_file_upload_function');
function my_custom_file_upload_function() {
    // Add custom functionality for file uploads
}

Adding custom functionality for image uploads

This example adds custom functionality for image uploads in the legacy media popup.

add_action('media_upload_image', 'my_custom_image_upload_function');
function my_custom_image_upload_function() {
    // Add custom functionality for image uploads
}

Adding custom functionality for video uploads

This example adds custom functionality for video uploads in the legacy media popup.

add_action('media_upload_video', 'my_custom_video_upload_function');
function my_custom_video_upload_function() {
    // Add custom functionality for video uploads
}

Adding custom validation for audio uploads

This example adds custom validation for audio uploads in the legacy media popup.

add_action('media_upload_audio', 'my_custom_audio_validation_function');
function my_custom_audio_validation_function() {
    // Add custom validation for audio uploads
}