0

I recently took over a website that uses a flat media folder in the site root. Is there a benefit to that over using the standard WordPress media folder structure of uploads/year/month/file?

We have been experiencing some issues with images on the website and I'm trying to understand if this could be contributing to the issues. At various times, we have been unable to upload images and, when we can upload images, it goes slowly. We also have had difficulty accessing the media folder via FTP. My guess was that it takes a long time to index a single directory with a ton of files than it does to index the standard structure.

We're also making an effort to improve performance. If having a flat folder degrades performance, we want to resolve that.

0

1 Answer 1

1

I recently took over a website that uses a flat media folder in the site root. Is there a benefit to that over using the standard WordPress media folder structure of uploads/year/month/file?

Not particularly, mostly preference. Some people might do it thinking it enhances SEO, but I've seen no evidence to support that claim.

My guess was that it takes a long time to index a single directory with a ton of files than it does to index the standard structure.

This sounds plausible, but you shouldn't need to access this folder via FTP. Remember, the media library is not a file/folder viewer. Uploading things to the uploads folder doesn't make them appear in the media library, and deleting things in that folder does not remove them, it just creates broken images.

This is because when you upload a file it's represented in the database as a post of type attachment, and it's those attachments that are listed in the media library. They have post meta, post parents, their own template and URLs, and can even have comments if you add the comment functions to their templates

At various times, we have been unable to upload images and, when we can upload images, it goes slowly.

This could be due to the flat folder layout, but that's less likely. You would need to profile an upload using the simple uploader rather than the drag and drop. You would do this via a tool such as XDebug, or the query monitor plugin. Right now you do not have enough information to draw a conclusion and it could be many things.

2
  • Thanks for the answer. Perhaps I should have indicated that the media folder holds over 75,000 files. Media library itself is over 5,000 items. Not sure if that changes the answer.
    – juusui
    Dec 4, 2020 at 8:03
  • Also, definitely not trying to add media library items by FTPing to the media folder. But in trying to work with this and understanding the issue, I've accessed the media folder several times and thought it was noteworthy that indexing the folder takes some time.
    – juusui
    Dec 4, 2020 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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