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?

Members fund testing for the Drupal project. Drupal Association Learn more


j0nathan’s picture

+1 for the feature request, and subscribing.

OKKEP’s picture

+1 for request, subscribing.

'cause with custom field names it's impossible to use properly.

wjaspers’s picture

Status: Needs review » Active

Looks 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.

  1. Open fieldfield_paths.module.
  2. Go to line 31,
            'file_name' => array(
              '#type' => 'textfield',
              '#title' => t('File name'),
  3. Change '#type' => 'textfield', to '#type'=>'textarea'.
  4. Save and exit.

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:



Tested a retroactive update against ~15 items. Worked like a charm.

wjaspers’s picture

Status: Active » Needs review
wjaspers’s picture

Further 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.

j0nathan’s picture

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?

wjaspers’s picture

I 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!

j0nathan’s picture

Thank 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.

wjaspers’s picture

Status: Active » Needs review
403 bytes

Since I didn't know how to create a patch before ... here's the patch now!

Deciphered’s picture

Issue tags: +FileField Paths 2.x

The 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.


Golem07’s picture

The 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.

mostou’s picture

Version: 6.x-1.4 » 7.x-1.x-dev
Status: Needs review » Needs work

I assume the addition of "#maxlength" will be to this file for the 7.x branch:

I will try and test it out and upload a patch if it works. I have the issue when using tokens for referenced nodes.

mostou’s picture

Status: Needs work » Needs review
517 bytes

As suggested from Deciphered, maxlength is added.

Deciphered’s picture

Status: Needs review » Fixed
Issue tags: -FileField Paths 2.x

Fixed and committed.


Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.