Regenerate thumbnails after upload

Adding

$attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
wp_update_attachment_metadata( $attach_id,  $attach_data );

after

$attach_id = wp_insert_attachment( $attachment, $filename);

Fixed it.

tech