Support » Developing with WordPress » rename files uploaded with Gutenberg Image block

  • Resolved wpshushu



    The default image block has an *upload* button:

    I tried the following filter hooks to rename file names uploaded using this button before file is saved:

    – wp_handle_upload_prefilter
    – wp_handle_sideload_prefilter
    – wp_handle_upload
    – sanitize_file_name

    so far none worked. They seem to trigger only when the upload is done via the media library UI.

    Any ideas?

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


    “wp_handle_sideload_prefilter” fires on my site when I use that button. (verified via error_log() call) Are you sure your code is otherwise working properly?

    Thread Starter wpshushu



    I retested.

    Turns out I set my code snippet(with this plugin) to run “Only run in administration area”, I changed it to “Run snippet everywhere” and then it got triggered.

    I guess the “upload” button calls something from the front end (REST API?).


    • This reply was modified 1 week, 3 days ago by wpshushu.
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.