Currently images uploaded through my media fields just dump into the files directory. I would like to rename them and save them to a subdirectory of my choosing. Normally I would rely on the File (Field) Paths module to do this, and I've tried configuring it on my media fields, but currently File (Field) Paths is not compatible with media fields. I have also seen the File Entity Paths module, but it's still in alpha, has only 23 reported installs, and hasn't seen any maintainer attention in a year and a half, so I'm a little apprehensive about relying on it (assuming it works).

What is the current best-practice method for renaming media files and setting their file path on upload? I can't imagine I'm the only one trying to implement this feature, so how are people doing it?

Comments

sheldonkreger’s picture

I use the File Entity Paths module alongside heavily patched Media and File Entity modules 2.x-dev. My site has hundreds of thousands of files and it all works as expected :-)

I would avoid field-level configuration of directories for file attachment fields. Try to stick to a single global FE Paths configuration if possible. Simplicity is king.

Linux file systems can actually have issues with too many files in a single directory (even if you are using Gluster). Or, at least ours did. So, we have an FE Paths config which places files into hundreds of randomly generated file directories. That's going to be overkill unless you are dealing with hundreds of thousands of files like we are.

Remember, the file URI (the path to the file on the server) is always stored in the file_managed table that File Entity creates. So, you can easily see where your files actually live on the server using that table.

Please be very careful if you are upgrading from File Entity 1.x to 2.x. This process DROPS the file_managed table (!!!!!!)

Let me know if you have any more questions.

jstoller’s picture

I use the File Entity Paths module alongside heavily patched Media and File Entity modules 2.x-dev.
I can't say this instills a great deal of confidence in my decision to use the Media module. What sort of patches are you talking about? Do any of them impact the issue I'm discussing here?

sheldonkreger’s picture

The aplha releases of Media and File Entity are stable but not fully-featured. For example, there are shortcomings in file displays inside content (for example, there is no easy way to find and place links to file downloads inside content). We also needed special styling for different kinds of images inside content. We also have special legal agreements people have to agree to before they can access certain files on our site.

If your requirements are flexible, then you can make the alpha versions work well. However, if you need to customize functionality, you're really opening up a can of worms. There are no alternatives to the Media and File Entity modules.

Generally speaking, in Drupal, you can get a lot done quickly if you are willing to be flexible about the details of functionality. However, if you have to customize things, it is a lot of work. The Media module is no exception to that rule.

Chris Matthews’s picture

Status: Active » Closed (outdated)

Closing this issue as outdated. However, if you think this issue is still important, please let us know and we will gladly re-open it for review.
sincerely,
- the Drupal Media Team