WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to upload a PDF file with spaces in it, and I want to do this using the uploader in the rich text editor (really, I want other, less savvy people to be able to do it, so convoluted workarounds are not really an option). Trouble is, Wordpress (3.0.3) insists on replacing spaces with hyphens and lowercasing everything (despite the fact that it's just not necessary).

Can I stop this? Turn it off? Or is there an extension to thwart this behaviour? Even a manual edit to the PHP might be okay, if there's no alternative.

share|improve this question
"despite the fact that it's just not necessary" ... Google "File naming conventions" and you'll get a better idea of why filenames are converted. – t31os Dec 14 '10 at 20:00
I suppose that I have the luxury of using Wordpress on one particular server, but the authors want it to work on all of them, so yes, maybe I am being too harsh. Still, changing my metadata to fit the lowest common denominator is annoying. – detly Dec 15 '10 at 0:16
up vote 5 down vote accepted

"despite the fact that it's just not necessary"

I think you'd be surprised by how unnecessary looking stuff has a tendency of becoming absolutely necessary on some poorly configured servers.

Else yes, it can be overridden using filters. You're looking into overriding the stuff in sanitize_file_name(), which is located in wp-includes/formatting.php.

share|improve this answer
Sorry for the delay :/ When you say "overridden using filters," what do you mean exactly? There's an alternative to hacking on the source? – detly Jan 26 '11 at 17:41
sanitize_file_name() ends with a filter call, which allows you to completely override the functionality. – Denis de Bernardy Jan 27 '11 at 14:06

Your Answer


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.