Support » Developing with WordPress » Upload prefilter modal popup

  • Hey!

    I’m trying to develop a plugin and i’m using ‘wp_handle_upload_prefilter’ to check the filename of the uploaded attachment. I want to check if the filename is already uploaded and in that case present a dialog to choose another filename instead of just adding a number to the existing filename. DO you have any suggestions on how to achieve this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I can tell you that you cannot invoke a modal from a PHP action. It’s running server side and modals operate client side. By the time that filter fires the upload is going to happen if at all possible. Your code can change to filename, but it cannot get user input at that point.

    I think you’d need to override the JS that starts the upload. It could make an initial Ajax query to see if the file exists before actually starting the upload. It can then get user input before it’s too late to do so. Unfortunately, I cannot suggest in any detail on how to do that, I’m not that knowledgeable about the WP client side media UI.

    Thread Starter svunz

    (@svunz)

    Makes sense. Thank you so much for your input. I will try to investigate further on how to modify the UI part instead.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Upload prefilter modal popup’ is closed to new replies.