You may have noticed, often files uploaded to websites are poorly named. This shows through when users may download an image from a website, view a tooltip, the properties of the image, etc...

I made a patch that provides a config admin setting to enable the renaming of uploaded files to semantic match the node content.

Of course, the original uploadpath tokens are also applied to create the full path. This patch applies only to the, end, actual filename part of the filepath.

example: DCM1000x.jpg ---becomes--> my_actual_node_title_1b345f.jpg

The result filename:

  • Is renamed to a string based on the node title.
  • has characters except letters a-z and numbers 0-9 replaced with underscore _
  • is all lowercase
  • has a unique code (e.g a2b3ce5ff1) added to the end to prevent duplicate filenames.

See attached.

DT

CommentFileSizeAuthor
uploadpath.module.patch8.31 KBdavidwhthomas

Comments

davidwhthomas’s picture

Note: the above patch includes my other patch to allow uploadpath settings per node type etc...
DT

merilainen’s picture

has a unique code (e.g a2b3ce5ff1) added to the end to prevent duplicate filenames.

Why this? I think upload module appends always _0, _1 etc. to duplicate files. It would be nice to have the document name in a nice form if there are no duplicates in the folder.

davidwhthomas’s picture

Status: Needs review » Patch (to be ported)
davidwhthomas’s picture

Status: Patch (to be ported) » Closed (fixed)