The admin_head_{$content_func} WordPress PHP action fires in the admin header for each specific form tab in the legacy (pre-3.5.0) media upload popup.
Usage
add_action('admin_head_{$content_func}', 'your_custom_function'); function your_custom_function() { // your custom code here }
Parameters
- $content_func (string) – The dynamic portion of the hook name, referring to the form callback for the media upload type.
More information
See WordPress Developer Resources: admin_head_{$content_func}
Examples
Add custom CSS to the image upload tab
Add custom CSS styles to the image upload tab in the legacy media upload popup.
add_action('admin_head_media_upload_image_form', 'add_custom_image_upload_styles'); function add_custom_image_upload_styles() { echo '<style>.custom-style { color: red; }</style>'; }
Add custom JavaScript to the video upload tab
Add custom JavaScript to the video upload tab in the legacy media upload popup.
add_action('admin_head_media_upload_video_form', 'add_custom_video_upload_script'); function add_custom_video_upload_script() { echo '<script>console.log("Custom JS loaded for video upload tab.");</script>'; }
Change the title of the audio upload tab
Modify the title of the audio upload tab in the legacy media upload popup.
add_action('admin_head_media_upload_audio_form', 'change_audio_upload_tab_title'); function change_audio_upload_tab_title() { echo "<script>document.title = 'Custom Audio Upload Tab Title';</script>"; }
Add a custom notice to the gallery upload tab
Add a custom notice to the gallery upload tab in the legacy media upload popup.
add_action('admin_head_media_upload_gallery_form', 'add_custom_gallery_upload_notice'); function add_custom_gallery_upload_notice() { echo '<div class="notice notice-info">This is a custom notice for the gallery upload tab.</div>'; }
Add custom HTML to the document upload tab
Add custom HTML content to the document upload tab in the legacy media upload popup.
add_action('admin_head_media_upload_document_form', 'add_custom_document_upload_html'); function add_custom_document_upload_html() { echo '<div class="custom-html">Custom HTML content for the document upload tab.</div>'; }