Hi, i am currently hashing original file names of image uploads by using File (Field) Paths and File Hash in some fields, and pushing them into the private filesystem, which works well. e.g.:
[random:hash:tiger128,3].[file:ffp-extension-original]
Path: useruploads
Upload destination: private files
But only for file upload fields.
Using the TinyMCE editor however (drag & drop etc.) stores the file in a custom folder, but retains its original filename without hashing.
Is there any input filter around or should the TinyMCE Uploader manually be hooked to be processed by the File Hash or Path module(s)?
I'm not aware of any input filter - the src must point to the actual path, otherwise images won't display.
I'm also not aware of any way to define a hash pattern for drag and drop images. In no WYSIWYG editor I know.
What you could try is playing with the TinyMCE option
images_reuse_filenamevia alter hook (set it to false).The API provides
hook_tinymce_options_alterfor all sorts of manipulations.But then you'd still have no control over the actual pattern - the editor uses its own, something like mceclip0 (1, 2, 3)... Backdrop File will take care of uniqueness, but you'll end up with names like "mceclip7_99.jpg".
Another option would be to prevent drag-and-drop upload via
paste_block_dropoption. (I belief, people could still paste then, though.)If you really absolutely need a hash in the form you described, and you have to provide drag-and-drop upload, you'd probably have to replace tinymce-uploader.js with something custom (hook_library_alter).