Change image name during uploading sequentially

The sequencing part will be handled automatically by wordpress.

if you want to change the filename, you can do this :

function k99_custom_upload_name($filename)
{
  $info = pathinfo($filename);
  $ext  = empty($info['extension']) ? '' : '.' . $info['extension'];
  $filename="put your name here";
     return $filename;
 }

add_filter('sanitize_file_name', 'k99_custom_upload_name', 10);

Because wordpress will handle the sequencing , your files will be named :

  • put your name here.ext
  • put your name here1.ext
  • put your name here2.ext

etc.. etc..

an alternative (shorter) way , that would not require to handle the extension would be :

function k99_custom_upload_name($filename)
{
$post_for_id = $post->post_parent;
    $filename="put your name here -".$filename;
    return $filename;
}

add_filter(‘sanitize_file_name’, ‘k99_custom_upload_name’, 10);

In this case your files will be renamed like so :

  • put your name here-originalname.ext
  • put your name here-originalname1.ext
  • put your name here-originalname2.ext

etc.. etc..