With this patch, you can rename your file uploads. Normally, only the file name shows up. This adds an additional input field to supply a title for the file that is displayed instead.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Souvent22’s picture

Assigned: Unassigned » Souvent22
FileSize
6.37 KB

Made a better patch in the correct format. But, this is a good patch. DEF helps to be able to "describe" your file via a label instead of via the filename. I hope this gets to head soon. It's the little things that matter. :). I also made the label size larger, from 128 to 255.

Bèr Kessels’s picture

Hi,

please read http://drupal.org/node/22568 for how to submit patches.

But besides that, I do not think this feature will make it into drupal. The current upload system is aimed at simplicity. If you need a differnt name, you should rename it locally, or use a contributed file managing module. But that is just my opinion. Others might like it!

Boris Mann’s picture

It's a good idea. Does it make sense to have filename --> filepath mapping as part of the file API? I would certainly say that that should be part of the information stored (i.e. there is a column for "name" in the table), but it would be up to modules to implement this.

drumm’s picture

I don't see a way to edit the description.

Souvent22’s picture

Yes, if you go to the node, and you edit the node, you can edit the descriptions of the attachments.

m3avrck’s picture

Ber, in contrast, this patch doesn't make uploads anymore complex, rather provides some much needed functionality. When a file is uploaded right now, it's name is whatever the name of the document is plus extension... which as we know how file names are, can sometimes be quite unreadable. How many people are going to take the time to rename the file? Not too many people I've noticed (I deal with a client that has 100s of files, filenames is a *big* issue).

So all this patch does introduce a field to put a name for the file, makes 100% sense and I think this is *much* needed.

Tested patch, works great.

However, the title field (drumm where did you get description??? this is only a title field) should have a default value initially after the upload and this should be set to the filename, as that is how Drupal works currently. Then, if the user chooses, they can change the display name of the file, otherwise the default will be the filename, not breaking nor interfering with how Drupal currently handles files. Very smooth transition :)

Also, getting a small 'fuzzy' problem when appyling patch on line 404, please check and reroll clean patch against head, thanks!

Gábor Hojtsy’s picture

+1 on the functionality. We still use a custom file upload module on one of our sites, since the upload module allows no title (which we use as a caption) to be associated with an upload.

kkaefer’s picture

However, the title field (drumm where did you get description??? this is only a title field) should have a default value initially after the upload and this should be set to the filename, as that is how Drupal works currently.

First, I had this kind of functionality but I removed it because there could be a redudancy in the database. Now, if the title-field is empty, the module uses the filename. If it is not empty, thus contains a string, it uses the string. If you leave the field empty (the default setting), the filename is *automatically* used.

kkaefer’s picture

FileSize
6.38 KB

Hope this patch is better. I tried the patch from Souvent22 and patch said the following:

patching file database/database.mysql
patching file database/database.pgsql
patching file database/updates.inc
patching file modules/upload.module
patch unexpectedly ends in middle of line
Hunk #6 succeeded at 404 with fuzz 1.

The new patch runs without this fuzziness.

Bèr Kessels’s picture

I fail to see any need for this. Thus I -1 on this. Can we not rather improve the filenaming on the file.inc level?
I like the simplicity of the current upload module a lot, and I fear this will only add clutter for nearly all people using this module. Tose taht need advanced file tools, should use an advanced module IMO.

And last, but not least, i've looked all file handling mechanisms I know, last days, and not one has a filed to change the name. I checked gmail, gmx, squirrelmail, ccmixter, mp3.com (alikes) etc.

So I stick with my -1 ,for IMO it only adds clutter yet I cannot see anyone using it.

What about a joint effort to get a single good advanced-uplaod.module from the ground? One that takes te best of all the alternatives around in a single project? And offers features like file renaming etc.

kkaefer’s picture

Can we not rather improve the filenaming on the file.inc level?
I like the simplicity of the current upload module a lot, and I fear this will only add clutter for nearly all people using this module. Tose taht need advanced file tools, should use an advanced module IMO.

First of all, I think improving the filenaming is not a very good solution and I doubt that it's simpler than just adding a title field for every file. You would also have to provide a proper file name for every file but the disadvantage is that you still have the file extension (i.e. *.pdf).

And last, but not least, i've looked all file handling mechanisms I know, last days, and not one has a filed to change the name. I checked gmail, gmx, squirrelmail, ccmixter, mp3.com (alikes) etc.

Well, that would be an argument against file renaming on file.inc-level - not against giving files a title. The reason why e-mail services do not provide an option to change the title of a file is, that there is no possibility to transmit this title while sending an e-mail.

So I stick with my -1 ,for IMO it only adds clutter yet I cannot see anyone using it.

Well, in this thread are already some people who appreciate a functionality like this (Souvent22, Boris Mann, m3avrck, Goba and of course me). As m3avrck said, this patch does not complicate or clutter anything.

What about a joint effort to get a single good advanced-uplaod.module from the ground? One that takes te best of all the alternatives around in a single project? And offers features like file renaming etc.

Again, I do not think that this is a good idea. I really think there is a need for titling files for almost every user. Also, my solution does not complicate anything if you don't want to give your files a title - just leave the title field blank and the filename is used automatically.

And one last question: Did you install this patch or did you just read the description and decided that you don't need/want this functionality?

Bèr Kessels’s picture

And one last question: Did you install this patch or did you just read the description and decided that you don't need/want this functionality?

Both. But if i so strongly object, I first want to have a good look, thus I applied it and tried it, and saw no real use for it. Sorry.

m3avrck’s picture

Ber while I agree with what your saying, I do see real value in this simple patch. I also agree that we should work collaboratively on a better upload manager for sure.

But the benefit of this patch is this: I have a client A who attachs a bunch of files to a node. At the bottom it says:

Attachments:
something_working 23_version2.pdf
coolNew features.wow.socool_3.doc
and etc...

Now what the heck does that mean??? Can't we just use a simple title field to setup an "alias"? That would make much sense. Then it'll be readable by all, ya see what I mean?

And timnc, I would still vote for having the title field in by default with the filename. This makes it clear to the user that this is what the title will be. Othewise, if it is blank, I wasn't sure what the title would be, if there would be one. It was *not* clear at all.

Also, this isn't a redunancy in the database. The filename and title can be the same thing or different, this isn't a redunancy, since they both have seperate and distinct meanings. Sure they might share the same name, but this *technically* isn't redudant, as there is no way to normalize this occurence. So I say put it back in for practicality's sake and to clear up any confusion :)

robertDouglass’s picture

I have been following m3avrck's arguments and am in total agreement. I'll test the patch as soon as I can.

kkaefer’s picture

Also, this isn't a redunancy in the database. The filename and title can be the same thing or different, this isn't a redunancy, since they both have seperate and distinct meanings. Sure they might share the same name, but this *technically* isn't redudant, as there is no way to normalize this occurence.

Well, you have convinced me. :)

m3avrck’s picture

Awesome! Care to reroll a patch with this fix? I think we can get this in tomorrow ;)

kkaefer’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
6.4 KB

This patch automatically sets the file name as title if no title is provided. Also fixed a fuzzy problem due to cvs database update.

This patch is ready to be committed.

Bèr Kessels’s picture

Did anyone test this on an installation using other modules that use the files table, such as image module, to see if that not completely breaks? For they have no access to the title, nor care to set one.

kkaefer’s picture

I have tested it with image.module and it works fine. No issues. The field in the database is defined as not null default ''. And if a module does not provide a title for the file, the field is simply empty. And if the field is empty, the filename is used by default.

So no problems here.

Souvent22’s picture

I reviewed this patch also. All seems well, I believe this is ready to go. +1.

m3avrck’s picture

Status: Reviewed & tested by the community » Needs work

Patch works great! However, please change the updates.inc to conform to the note at the top of the file. Updates have changed now since MySQLi support was added. Use the switch() syntax. Then this patch will be ready to be committed and I'll get it the famous +1 ;)

kkaefer’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
6.37 KB

added mysqli to updates.inc

m3avrck’s picture

Looks good to me!

Dries’s picture

Status: Reviewed & tested by the community » Needs work

Coding style needs work -- incorrect use of spaces.

m3avrck’s picture

Also needs to be rolled for HEAD.

kkaefer’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
6.34 KB

Corrected the database stuff.

Dries: I see no wrong coding style that comes from my patch. I ran the code-style.pl-script and it said that some spaces are wrong, but that was not on the locations where this patch changes something. I checked all places the script found fault but they are all ok as that are things like multi-line array definitions.

m3avrck’s picture

FileSize
6.35 KB

timcn, I noticed a two small spacing issues which I have corrected in this patch. Dries, I went through line by line, no coding style issues stand out, I believe this is ready to go now.

Dries’s picture

Status: Reviewed & tested by the community » Needs work

Patch no longer applies.

m3avrck’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
6.41 KB

Updated patch against current HEAD.

kkaefer’s picture

FileSize
6.39 KB

Updated against HEAD.

Dries’s picture

How about changing title to description? It does the same, but it is more flexible.

m3avrck’s picture

Good idea Dries, description does do a better job.

@timcn, can you reroll the patch with this change? I would do it but don't have access to my dev box right now, I can do this on Monday though if it already hasn't been updated.

Dries’s picture

Let me know when it's ready. ;)

m3avrck’s picture

FileSize
6.49 KB

Updated patch. Title -> Description ready to go, applies cleanly to HEAD :)

Dries’s picture

Please rename 'filedescription' to 'description'. Should be easy enough, and ready to be committed after that change.

m3avrck’s picture

FileSize
6.42 KB

Updated.

@Dries reason I put filedescription earlier was to be consistent with the rest of the files table, all of the fields are "filemime", "filesize" etc... "description" it is kind out of place on that table.

However I do agree that just description is best, but maybe all of the other fields should have the word "file" taken out as well since that is redundant. Your call, this patch has just "description" and one above is "filedescription".

pz’s picture

Be sure to check against sql reserved words, if I remeber correctly both "path" and "size" are reserved.

Uwe Hermann’s picture

I checked that at http://developer.mimer.se/validator/sql-reserved-words.tml, "description" should be fine.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed modified version of this patch. Thanks.

kkaefer’s picture

Sorry m3avrck, I was unable to check drupal.org the last few days...

m3avrck’s picture

No prob timcn, glad the patch went in regardless, we needed this functionality too!

Anonymous’s picture

Status: Fixed » Closed (fixed)