I want an admin notice box on all media upload pages. I did that for media library page by code

  add_action( 'load-upload.php', array( $this, 'media_library_message_load' ) );
  public function media_library_message_load(){         
         add_action( 'admin_notices', array( $this, 'media_library_message_display' ) );

  public function wpb_media_library_message_display() {         
            echo '<div class="notice update-nag">
                    <strong>Note: my message </strong>

But i want this message on add media popup screen also . But i am not founding any solution.


1 Answer 1


I'm unaware of any hooks that tap in in the pop up, but there might be.

If not, you could use some jQuery to put your message on the pop-up when Add Media is clicked. I was able to with the following:


function myplugin_add_media_popup_notice() {
    jQuery(window).load(function() {

        // the MEDIA buttons you want the notice on
            // give the lightbox half a second to add itself
            setTimeout(myplugin_add_media_popup_notice, 500);

        function myplugin_add_media_popup_notice() {

            // if we haven't added a notice already
            if (!jQuery('body').hasClass('addedMediaPopUp')) {

                // the the notice
                jQuery('.media-frame-router').before('<div class="update-nag notice"><strong>Note: my message </strong></div>');    

                // and mark it to not show again if media btn reclicked
        /* and some css since .notice isn't completely defined at this scope */
        .media-frame .update-nag.notice {
            position: absolute;
            top: -10px;
            right: 40px;
            z-index: 999;
            width: calc(100% - 600px);
            border-left: 3px solid #168fc0;
            box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.