Support » Fixing WordPress » Image File Name Shortened (Truncated) by WordPress

  • I thought to post this one to WordPress in-case others have the same issue.

    Problem
    Uploading an image, WordPress truncates (shortens) the image name to something like, “imagenam~.jpg”.

    This then seems to not make sense because before, you have experienced the same length image name show as accepted by WordPress, but suddenly WordPress shortens it, so Why?

    Fix
    Move the image to the desktop, then try uploading it again. If WordPress still shortens it, then move it to a temp folder at the root “C:\”, which shortens the file path to the bare bones length. Try again, if the same issue appears, rename the image so the image file name is shorter.

    Reason
    It has to do with one or both limitations of Windows. The depth of the folder (file path) and/or the length of the file name itself. The file name length per Windows limit, I believe, is about 256 characters, including spaces.

    The culprit most of the time, in my experience, is the depth of the file location. Too many sub-folders will cause this issue, even if the file name is already short. The moving of the image file to the desktop or to a temp folder at the root (C:\) will resolve the issue.

    As I understand Windows, the depth of the file (sub-folder location) has a bearing on how large the file name can be. This means the file name character limit of 256 characters gets less and less the deeper the file is located.

    Also, if the folder name itself is longer or long, that also has an impact on the file name length of files within that folder.

    As I have experienced, WordPress image library upload is also affected the same way.

    As a note, FTP uploads are also affected the same way, if you find a file was not accepted during the upload or its file name was shortened, then the depth of the file location was likely the cause.

    Question to WordPress Support
    What is the limit to an image file name length per WordPress? – is it the same as Windows or different?

    • This topic was modified 2 years, 10 months ago by wpwd2016.
    • This topic was modified 2 years, 10 months ago by wpwd2016. Reason: added more info
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, just uploaded an image file named literally:
    now-thats-a-really-really-really-really-really-long-file-name-for-an-image-file-to-try-to-upload-it-in-wordpress-media-manager-using-standard-functions.png
    Seems to be fine in Media Manager.

    However, the “imagenam~.jpg” is 8 characters long followed by a “~”, which suggest something like a browser that reads the “8.3 alias” of the file and uploads that instead of the regular long-named file. Are you using an older version of Windows?

    OR maybe your website is hosted on a Windows server and PHP is configured somehow that doesn’t pass the long name to it?

    Few more details about these would come in handy 🙂

    Best,
    Alex.

    Thread Starter wpwd2016

    (@mwarbinek)

    I am using Windows 10, my browser is the current version of WaterFox (FireFox 64bit).

    What I posted is what I found out by my own investigation and this investigation was on my own computer, not on the server.

    I copied the folder with the images from the deep sub-folder position to the Desktop and the fine name error was resolved.

    I went to that sub-folder location and tried to rename the image file and Windows 10 refused to accept a longer name, where the image file name was already 28 characters long.

    With that same image file (copied) to the desktop, I renamed the file name to be longer than 28 characters and Windows 10 accepted the change.

    If you want to test it, create a subfolder depth with folder names also a few words in length. Keep going on the depth and see what happens.

    Example, the subfolder depth for my image was,
    C:\Users\(username)\Desktop\(folder name length)\(folder name length)\(folder name length)\(folder name length)\(folder name length)\(folder name length)\(folder name length)\(folder name length)\(file name).

    Generally, most people will not face this issue and all will be fine, but for those who do business via the web and building websites, images, client folders & information, etc etc, then sub-folder depth will likely occur more often.

    In regards to server limitations, so far I have not had issues with any server, but that is not to say some hosting services may place a limit on file name length size.

    Remember what I said, the acceptance of an image file name without it being automatically shortened depends on 3 things, individually and collectively,

    1. the name length of the image file itself,
    2. the folder location of that image file (how deep it goes) and,
    3. the name length of each folder as it goes down to that image file location.

    All of that determines if WordPress will truncate the file name or not.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Image File Name Shortened (Truncated) by WordPress’ is closed to new replies.