How can i display gallery shortcode output under Post text

The do_shortcode() function returns the shortcode output as a string, which can be appenend to the post content with the_content filter. Here’s an example how to do that,

// add filter with late priority
add_filter('the_content', 'my_post_attachments_gallery', 99);
function my_post_attachments_gallery($content) {
    // modify only published posts
    if (
        is_singular( 'post') &&
        'publish' === get_post_status()
    ) {
        // get attachemnt ids
        $attachment_ids = my_post_attachment_ids();
        if ( $attachment_ids ) {
            // do_shortcode returns the shortcode output as a string
            // which we can append to the content
            $content .= do_shortcode('[av_gallery ids="' . implode(",", $attachment_ids) . '" type="slideshow" preview_size="large" crop_big_preview_thumbnail="avia-gallery-big-crop-thumb" thumb_size="portfolio" columns="' . count($attachment_ids) . '" imagelink="lightbox" lazyload="avia_lazyload" av_uid="av-jgesnq4m" custom_class="av-gallery-style-"]');
        }
    }
    // return content back to the_content filter
    return $content;
}

// helper function
function my_post_attachment_ids( $post = null ) {
    $post = get_post($post);    
    $query = new WP_Query(array(
        'post_type' => 'attachment',
        'posts_per_page' => 500,
        'post_parent' => $post->ID,
        'exclude'     => get_post_thumbnail_id($post),
        'no_found_rows' => true,
        'update_post_meta_cache' => false,
        'update_post_term_cache' => false,
        'fields' => 'ids',
    ));
    return $query->posts;
}

With the helper function we can skip the foreach loop and save a few lines as the custom query returns just the attachment IDs, which the shortcode needs. And with the couple extra parameters we can skip some processing and make it the query a little faster.