• I like to use dashes in my image filenames but when I upload files using the WordPress upload feature, it removes the dashes. For example, if I upload a file named ‘cool-blog-image.gif’ the file is renamed ‘coolblogimage.gif’ when it is saved to the server.

    Does WordPress dislike dashes in uploaded filenames for some reason? Or, am I just doing something wrong?

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • $img1_name = preg_replace("/[^a-z0-9_.]/i", "", $img1_name);

    If I’m reading that right the only allowed characters are a-z, 0-9, underscore, and period. All others are removed.

    Thread Starter plucky

    (@plucky)

    Ah, I see. Thanks for the pointer. I added a dash to the end of the regex and now my filenames are untouched. Goodness.

    Any idea why they want to sanitize filenames so much?

    This should certainly be classified as a bug. Filenames for larger sites can get quite large, and dashes certainly aid in readability. I find it sufficiently irritating to have my dashes removed that I’ve started just using an FTP client.

    I have no idea where to post a feature request, but I have one along these lines. There ought to be a subset of the image upload function that takes the name of the image and appends the date, to make massive blogs’ (of which I have several) image directories easier to deal with. I name all of my images in the format of YYYYMMDD-description.jpg and YYYYMMDD-description-thumb.jpg, when the image has a corresponding thumbnail. I do this naming by hand, which can be rather laborious. If I needed only upload a series of images and automagically have the thumbnail made, named accordingly, and the date prefix added, it would be a wonderful thing, indeed.

    It’s worth noting I created an account for the purpose of replying to this thread. The account name requested was “Waldo Jaquith.” Then came the confirmation screen, telling me that the account name “WaldoJaquith” had been created.

    Ironic, no? This seems like something that needs consideration WordPress-wide.

    Bugs go here: http://mosquito.wordpress.org/main_page.php

    As for your 2nd thing, I don’t recall many places around the web that will allow you to have a space in a username. That’s just common practice.

    I’ve developed authentication-based web applications since 1998. All systems that I’ve ever constructed have permitted spaces, and it’s never occurred to me to do otherwise. There’s no reason <i>not</i> to allow spaces. And if I <i>weren’t</i> going to allow spaces, I would alert the user to that fact and provide them with an opportunity to try a different username, rather than just ereg_replacing them without comment.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘dashes not allowed in uploaded filenames?’ is closed to new replies.