Answers.Body: <p>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. </p>
  
  <p>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 <code>{dateCreated|date('Y')}/{dateCreated|date('m')}/{slug}</code>.</p>
  
  <p>Also note that if this is being used in a Matrix block, you'll have to prefix all those variables with <code>owner.</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-12T12:19:03.460Z
Answers.LastActivityDate: 2017-04-12T12:19:03.460Z
Answers.UserDisplayName: Andris Sevcenko
Body: <p>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 <code>{slug}</code> 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).</p>
  
  <p>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.</p>
  
  <p>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 <code>{slug}</code>)?</p>
  
Tags: <assets><control-panel>
Title: How to deal with too many folders in asset source?
ThreadText: # How to deal with too many folders in asset source?
  
  (Asked by: username_0 on 2017-04-11)
  
  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}`)?
  
  **Tags:** assets, control-panel
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-04-12. Score: 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.`
  
  
  ---
  
  