Support

Account

Home Forums Backend Issues (wp-admin) Detect which field is in use while uploading file Reply To: Detect which field is in use while uploading file

  • Hello @elliot!

    Buddy, is there some news on this point?

    I’m working on a project that need to rename certain uploaded files, and I’m trying to do this with a WP hook (sanitize_file_name):

    function new_filename_hash($filename) {
        $info = pathinfo($filename);
        $ext  = empty($info['extension']) ? '' : '.' . $info['extension'];
        $name = basename($filename, $ext);
        return md5($name) . $ext;
    }
    add_filter('sanitize_file_name', 'new_filename_hash', 10);
    

    It’s ok, but furthermore, I also would like to include some string based on the field name, but I get the same limitations of our friend @k12m.

    I think that your ajax suggestion could be a great solution, but I’m asking you about this just in case of a novelty 🙂

    Thank you!