Make WordPress Core

Opened 2 years ago

Last modified 8 months ago

#19121 new enhancement

Add filter to wp_unique_filename

Reported by: xazure Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 2.5
Component: Filesystem API Keywords: has-patch needs-refresh
Focuses: Cc:


Add a filter to wp_unique_filename so it can be modified if necessary.

Currently in wp_handle_upload I am trying to use FTP to put the file elsewhere. Since I can can't use an FTP protocol with move_uploaded_file, I can't just use the upload_dir filter to change the upload directory.

I need to be able to change the unique name directly (so I can look on my FTP server) and then later on I'll handle the move.

There is no way to access this (you can't just affect overrides or anything like that) without completely rebuilding large portions of the uploader. With this one minor hook added, the flexibility becomes much greater.

Attachments (2)

19121.patch (353 bytes) - added by SergeyBiryukov 2 years ago.
19121.2.patch (359 bytes) - added by SergeyBiryukov 2 years ago.
With $ext

Download all attachments as: .zip

Change History (8)

SergeyBiryukov2 years ago

comment:1 SergeyBiryukov2 years ago

  • Keywords has-patch added

wp_unique_filename() has $unique_filename_callback, but it doesn't seem to be possible to specify it for core media upload (see #20057 for context), unless I'm missing something.

We can probably add a filter there in the same way we did for wp_unique_post_slug() in #14111.

SergeyBiryukov2 years ago

With $ext

comment:2 archon81021 months ago

Any movement here? I'd love to see this in core.

comment:3 archon81021 months ago

  • Cc admin@… added

comment:4 markoheijnen21 months ago

I would love to see this in 3.5. I think it's fine to only add a filter for the callback and not on the return value

comment:5 husobj21 months ago

  • Cc ben@… added

comment:6 c3mdigital8 months ago

  • Component changed from Upload to Filesystem
  • Keywords needs-refresh added
  • Version changed from 3.3 to 2.5
Note: See TracTickets for help on using tickets.