Pagination with WordPress default gallery?

Ended up like this. Made this changes and it worked:

changed:

'base' => str_replace($big,'%#%',esc_url(get_pagenum_link($big))),

into:

'base' => get_permalink( $post->post_parent ) . '%_%',

And changed:

'format' => '?paged=%#%',

into:

'format' => 'paged=%#%',

Then added a filter with rewrite tag and rule:

add_filter('init', 'post_gallery_add_rewrite_tag_rule_2022');
function post_gallery_add_rewrite_tag_rule_2022() {
    add_rewrite_tag('%current%','([^&]+)');
    add_rewrite_rule('([^/]+)/paged=/?([0-9]{1,})/?$', 'index.php?name=$matches[1]&paged=$matches[2]', 'top');
}

Then (after uploading functions.php) in WordPress admin panel:

Settings -> Permalinks -> [ Save Changes ]