1

In D8, where to change the Public File System Path to be :

sites/default/files/[nodeID]/

Do I need write a module?

1 Answer 1

2

You can't change the public file system path globally to include a nodeID because there are things that can store files that do not have a nodeID (such as non-node entities).

Instead, you can change where files are stored per file storage field (examples: File fields and Image fields).

To do so, go to Structure -> Content Types -> My Content Type -> Manage Fields and then choose Edit for the relevant field.

Then, in File directory, you can use tokens to set up the path however you like. For example:

myfiles/[date:custom:Y]-[date:custom:m]-[date:custom:d]

There is a link below Help text that you can click to see a list of available tokens.

3
  • 1
    Use File (Field) Paths if you need extra tokens.
    – No Sssweat
    Dec 5, 2017 at 6:15
  • Is adding an author ID to the path a good practice? like `content_type/[node:author]/[date:custom:Y]-[date:custom:m] Dec 6, 2017 at 21:26
  • @johnatasjmo You can configure that path however you want. My main concern when setting the path is making sure I add any variables I will want to use as arguments (contextual filters) in Views later. Dec 7, 2017 at 3:37

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.