page shows short code not output

I change the array in get_children() and foreach loop with below reference url and code work fine. please check the argument that you have passed also use echo statement like they shown in the example.

reference url : https://developer.wordpress.org/reference/functions/get_children/

let me know result or errors

$args = array(
    'posts_per_page' => 1,
    'order'          => 'ASC',
    'post_mime_type' => 'image',
    'post_parent'    => $post_id,
    'post_status'    => null,
    'post_type'      => 'attachment',
);

$attachments = get_children( $args );

if ( $attachments ) {
    foreach ( $attachments as $attachment ) {
        $image_attributes = wp_get_attachment_image_src( $attachment->ID, 'thumbnail' ) ? wp_get_attachment_image_src( $attachment->ID, 'thumbnail' ) : wp_get_attachment_image_src( $attachment->ID, 'full' );
        echo '<img src="' . esc_url( wp_get_attachment_thumb_url( $attachment->ID ) ) . '" class="current" />';
    }
}