Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

After a couple of hours searching the WP core I've lost hope finding this myself (for once).

Could someone guide me perhaps to where WordPress handles the incremental number when having duplicate file names during uploading?

As a side question. When handling questions like this, where and how would you start searching? AFAIK I've searched through every file containing file and upload.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The number is added in wp_unique_filename() in wp-includes/functions.php. You can prevent it by hooking into 'sanitize_file_name' and setting another file name.

You can find such functions and filters by following the code with your IDE. Most IDEs make functions clickable so you can go from their call to their declaration.

Here is an example from Eclipse PDT:

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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