I've got a channel with over 1,000 pages, and the entries for this channel have an asset field (for images). I set the asset field to use {slug} as the folder name (because otherwise the content author would have to wade through thousands of photos to find the ones for a certain entry), and so now I have thousands of folders in the asset source's folder in the filesystem. (Just using the server filesystem here, not S3/rackspace/etc).

Problem is, now when you try to expand that asset source in the asset manager sidebar, the page just crashes. Running latest version of Craft (2.6.something), PHP 7, on a beefy VPS server... client is most recent version of Chrome on a modern MacBook with plenty of RAM, etc... so this is not a problem of too few server or browser resources.

My question is: assuming there is some practical limit to the number of folders that the asset manager UI can deal with (which is what, by the way?)... what's a good strategy for me to handle this situation? Each of these thousand+entries will have at least one image, some up to a dozen (this is a fairly large product catalog site). Is there a better way to organize the folder structure, or perhaps a better way to dynamically generate the sub-folders (as opposed to {slug})?

1 Answer 1


As you have deduced, Assets have a fair amount of javascript attached to each folder and file to deal with all the dragging and dropping. To save resources, a folder gets initialized only when it becomes visible. So, if you're exposing a thousand of those folders at the same time, the JS engine will take quite a hit and consume huge amounts of resources.

In my experience, a good way of mitigating is dividing the subfolders by years and months. Since an entry might not have a post date yet when it's being edited and the post date might change over the course of an entry's lifetime, the path I've come to rely on is {dateCreated|date('Y')}/{dateCreated|date('m')}/{slug}.

Also note that if this is being used in a Matrix block, you'll have to prefix all those variables with owner.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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