Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm not sure why the "File name:" field is limited to 130 characters, but its impeding my ability to use all the tokens I want.
Is there any way to extend it to a full 255 characters?
Comment | File | Size | Author |
---|---|---|---|
#13 | filename_field-860848-13.patch | 517 bytes | mostou |
#9 | filefield_paths-860848-3.patch | 403 bytes | wjaspers |
Comments
Comment #1
j0nathan CreditAttribution: j0nathan commented+1 for the feature request, and subscribing.
Comment #2
OKKEP CreditAttribution: OKKEP commented+1 for request, subscribing.
'cause with custom field names it's impossible to use properly.
Comment #3
wjaspers CreditAttribution: wjaspers commentedLooks like we may be able to blow by 255 characters.
I took a look at teh database design, and everything appears to be safe for this fix.
'#type' => 'textfield',
to'#type'=>'textarea'
.WARNING:
If you're using CKEditor, or any WYSIWYG that replaces textareas, you'll need to turn OFF this field definition.
By ignoring it, you will accidentally get html in your filenames!
My suggested exclusion rule is this:
EDIT:
Tested a retroactive update against ~15 items. Worked like a charm.
Comment #4
wjaspers CreditAttribution: wjaspers commentedComment #5
wjaspers CreditAttribution: wjaspers commentedFurther testing and development will be needed to prevent filename problems.
I recently discovered if a stray line break ("\n") is present, it will cause FileField_Paths to break your tokenized path. The result is a WARNING when saving your content, and your file will be saved as: <file-name>_n_y.<file-extension>.
Where "n" is the duplication number (0 for first time, 1 for second ... etc), and y (is the duplication of the duplication number). If left unchecked, I presume this could continue exponentially.....
_n_y_n_y_n_y_n_y .... and so on.
Comment #6
j0nathan CreditAttribution: j0nathan commentedHi,
I am no DBA nor programmer, but I don't feel comfortable with a textarea when it should be a text field on only one line without HTML. Maybe I'm worrying too much?
Comment #7
wjaspers CreditAttribution: wjaspers commentedI don't think its a serious issue. Especially if the module maintainer filters the textarea's contents.
As a MySQL Developer myself, I understand your concern. Basically, you don't want incorrect data slipping into your database. The database field for your FileField_Paths instance is actually of type MediumText, which allots enough space for all of this data anyway.
It has not happened to me--even when I discovered the flaw in my code change. I assume other modules like: FileField (required here anyways), ImageCache or the ImageAPI module catches the filesystem error before committing the change to the database. Instead of saving your mistake, the filename is logically corrected and saved that way instead.
Because Windows, Unix, Linux, etc... filesystems allow 255 (and some longer) filenames, you could really squeeze every character out of your file renames with a textarea. Not to mention, its way easier for site administrators to read!
Maybe the idea is to utilize a textarea, and using another field, replace line breaks ("\n") with your choice of "-","_","+", or other character?
I'd really hope to hear from our illustrious maintainer soon on this!
Comment #8
j0nathan CreditAttribution: j0nathan commentedThank you wjaspers for your explanation.
I don't know what to say about your suggestion of using another field. You'd be better than me for this.
I'll wait and see what others will say.
Comment #9
wjaspers CreditAttribution: wjaspers commentedSince I didn't know how to create a patch before ... here's the patch now!
Comment #10
Deciphered CreditAttribution: Deciphered commentedThe correct way to make this change should be to add
'#maxlength' => 512,
in filefield_paths.module after line #33, in the same fashion as it is done for the File path, however the field has been increased to 512 characters in my internal development version of the 2.x branch, which I should hopefully release a alpha/beta/dev version within the week.Cheers,
Deciphered.
Comment #11
Golem07 CreditAttribution: Golem07 commentedThe problem seems to have become even bigger in the 7.x branch since the tokens are a lot longer now.
A simple token for a user profile takes up 56 characters on my test page (though the actual path would take up less that 10 characters). So in some cases it is nearly impossible to use more than one token for the path.
Comment #12
mostou CreditAttribution: mostou commentedI assume the addition of "#maxlength" will be to this file for the 7.x branch:
\modules\filefield_paths.inc
I will try and test it out and upload a patch if it works. I have the issue when using tokens for referenced nodes.
Comment #13
mostou CreditAttribution: mostou commentedAs suggested from Deciphered, maxlength is added.
Comment #14
Deciphered CreditAttribution: Deciphered commentedFixed and committed.
Thanks.