How to add a caption to an image attachment in a file list?

You simply need to pass $attachment_id instead of get_post_thumbnail_id() in echo get_post(get_post_thumbnail_id())->post_excerpt; with wptexturize to prevent your markup from breaking other things.

Update: As @birgire suggested I think it is better to use get_post_field() instead of directly accessing post property.

Updated code:-

function soth_output_gallery_file_list( $file_list_meta_key, $img_size ) {

    // Get the list of files
    $files = get_post_meta( get_the_ID(), $file_list_meta_key, 1 );

    echo '<div class="entry-content row">';

        foreach ( (array) $files as $attachment_id => $attachment_url ) {
            echo '<div class="small-6 medium-4 column text-center">';
            echo wp_get_attachment_image( $attachment_id, $img_size );
            echo '<p class="wp-caption-text">';

            //Get post excerpt by attachment ID
            echo wptexturize( get_post_field( 'post_excerpt', $attachment_id ) );
            echo '</p></div>';
        }

    echo '</div>';
}

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