Remove echo from shortcode

‘echo’ statement will not work in shortcode function. shortcode function is just returning the variable; So your code will be like this:

if(get_field('group')) {
    $html="";
    $html.= "<ul class="sponsors"><h2>" , get_the_title() , "</h2>";

    while(has_sub_field('group')) {

        $attachment_id = get_sub_field('image'); 
        $size="sponsorimage"; 
        $image = wp_get_attachment_image_src( $attachment_id, $size , false );

        $link = get_sub_field('link');

        $html.= "<li>";
        $html.= "<a href="" , $link , "" target="_blank">";
        $html.= "<img src="" , $image[0] , "" />";
        $html.= "</a>";
        $html.= "</li>";
    }
    $html.= "</ul>";
}
endwhile; endif; wp_reset_query();

return $html;

tech