Shortcode function doesnt work without caption

This code requires both a width greater than or equal to 1, and a caption. You could try removing these lines:

if ( $atts['width'] < 1 || empty( $atts['caption'] ) )
    return $content;

That may affect other functionality, but it is the point where the script skips the image entirely.