Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Rename files during upload within Wordpress backend

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 242
    Comment on it

    If you want to rename the file name at the time of upload, it is a right place to know the solution. Let's discuss this requirement.

    We all know there are many hooks available in Wordpress. We will use the filter named sanitize_file_name. You can simply put the code in function.php

    function renameMedia($medianame)
    {
        $data = pathinfo($medianame);
        $newName = basename($filename);
        return md5($newName) . '.' . $data['extension'];
    }
    add_filter('sanitize_file_name','renameMedia');
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: