Let me describe what I'm trying to accomplish. My client wants the ability to rename uploaded files for better SEO in image searches. The solution we came up with uses Filefield Paths to rename the file based on the file description using the following replacement pattern:

[filefield-description].[filefield-extension-original]

This works very well, unless the content editor forgets to add a description, in which case the file is saved as something like ".jpg", ".jpg_0", ".jpg_1", etc. In this case, it would be helpful if Filefield Paths would fall back to the original filename. I can see a couple ways this could be done.

1) Expose a token like [filefield-description-with-fallback], which would use the original filename if the description was empty.

2) Offer a checkbox setting like "Use original filename if replacement pattern is empty" on the field settings page, which again would use the original filename if the pattern was empty, or was only an extension.

Are one of these two options possible?

CommentFileSizeAuthor
#1 filefield-description-or-onlyname.patch1.06 KBtohojo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tohojo’s picture

I've been having this exact same problem. Since no one seems to have bothered to do something about this, I made a quick implementation of it by patching the filefield module to provide a "filefield-description-or-onlyname" token that falls back to the "onlyname" (i.e. name without file extension) if the description field is empty.

It should be pretty straight-forward to adjust this to fall back to any other field if required.

See attached patch.

Deciphered’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

No longer supporting Drupal 6 issues for this module.