Jump to content

Creating my own folders for image assets


aren
 Share

Recommended Posts

Hey guys,

Why does ProcessWire automatically creates folders for each page images?

Is it possible to create and use my own folders for uploaded images? For example, I want a "projects" folder to store project images and a "blog" folder to store images from the blog. 

How can I do that?

Link to comment
Share on other sites

First of all, this is how ProcessWire asset management works, so instead of asking "why does it do this", I'd ask "why wouldn't it do this"? :)

Files, including images, are tied to Pages, and live under page-specific directories under /site/assets/files/. If you really need to change this behaviour, you probably can, but it'll require quite a bit of work -- and thought, as you'll have to find new ways for keeping asset names unique (two pages having a different file with same name and so on), handling secure files, removing files once they're no longer needed, etc.

In a nutshell: this is not something you can easily do. If you're ready to really get your hands dirty and rewrite a lot of what ProcessWire currently does with Pagefile, Pagefiles, PagefilesManager, ImageSizer, etc. then by all means do it (and we'll try to help), but I'd suggest against it.

Also: you should make sure that you have a really good reason to do this first. What are you trying to solve by moving assets to template-specific (assuming that's what you're referring to here) directories? How does it benefit the system, or the user? How does it scale, what kind of benefits and/or drawbacks does it introduce, etc.?

If there's something specific you're trying to achieve by this, please let us know. Perhaps there's an easier way to do it.

  • Like 2
Link to comment
Share on other sites

If I understand correctly, for that trick to work you don’t need to literally host your images in a seperate location. It should suffice to have a subdomain that points to the same paths you’re normally using. Basically, the benefit comes from loading images via a different domain, because it makes the browser allow a parallel connection. Not sure how relevant this is with modern browsers, though.

Link to comment
Share on other sites

Processwire already gives you all the tools for this. You can setup your own image fields and "page" trees

where you need them. You just have to think about how to group your "page" tree levels so can easily

administrate your images if you have a lot of them.

Link to comment
Share on other sites

Depending on your server, you can configure the whole /site/assets/files path to be accessible from a subdomain like files.example.com. Then you make sure that the image url you output matches this subdomain. This might be a small performance boost if the subdomain doesn't use a cookie.The AllInOneMinify modules uses such an option for example.

If you want to move them all to a different server/directory you would need to create our own custom FileHandler. PW doesn't have someting like the FileAbstractionLayer from Typo3.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...