Using WordPress ‘media_upload_text_after()’ PHP function

The media_upload_text_after WordPress PHP function displays a message after a file has been uploaded.


add_action('media_upload_text_after', 'your_function_name');


  • None

More information

See WordPress Developer Resources: media_upload_text_after


Add a custom message after media upload

Display a message to the user after they have uploaded a file.

function custom_media_upload_message() {
    echo '**File uploaded successfully!**';
add_action('media_upload_text_after', 'custom_media_upload_message');

Display additional instructions after media upload

Provide more information to users after they have uploaded a file.

function display_additional_instructions() {
    echo 'To insert the uploaded media into your post, click **Insert into post** button.';
add_action('media_upload_text_after', 'display_additional_instructions');

Show a reminder to add alt text

Remind users to add alt text to their uploaded images for better accessibility.

function remind_alt_text() {
    echo '**Reminder:** Please add alt text to your image for better accessibility.';
add_action('media_upload_text_after', 'remind_alt_text');

Display a message about image optimization

Inform users about image optimization and compression for faster page loading.

function image_optimization_message() {
    echo 'For better performance, consider optimizing and compressing your images before uploading.';
add_action('media_upload_text_after', 'image_optimization_message');

Show a custom message based on user role

Display a custom message to administrators after they upload a file.

function custom_message_for_admins() {
    if (current_user_can('administrator')) {
        echo '**Note for Admins:** Make sure to review the uploaded file before publishing.';
add_action('media_upload_text_after', 'custom_message_for_admins');