WordPress.org

Ready to get started?Download WordPress

Forums

dashes not allowed in uploaded filenames? (6 posts)

  1. plucky
    Member
    Posted 9 years ago #

    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.

  2. Nick Momrik
    Member
    Posted 9 years ago #

    $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.

  3. plucky
    Member
    Posted 9 years ago #

    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?

  4. Waldo Jaquith
    Member
    Posted 9 years ago #

    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.

  5. Nick Momrik
    Member
    Posted 9 years ago #

    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.

  6. Waldo Jaquith
    Member
    Posted 9 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.