Sadly adding the snippet to functions.php (or running it in a code snippet tool) has no effect. Images are not attached to tweets.