Change filename during upload

If you want to use the above sanitize_file_name filter, you could try this:

function make_filename_hash($filename) {

    if( isset($_REQUEST['post_id']) ) {
        $post_id =  (int)$_REQUEST['post_id'];
    }else{
        $post_id=0;
    }

    $info = pathinfo($filename);
    $ext  = empty($info['extension']) ? '' : '.' . $info['extension'];
    $name = basename($filename, $ext);

    if($post_id>0){
        return $post_id."_".$name . $ext;
    }else{
        return $name . $ext;
    }
}
add_filter('sanitize_file_name', 'make_filename_hash', 10);

where for example image.jpg is changed to 123_image.jpg where 123 is the parent post id.

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş