So...
if (userAgentIsTwitterPreviewBot() && weCareAboutTheShitFlingingIdiotsDyingPlatform()) {
return previewImageWithBurnedInCaption();
}
It might not even need code, just some extra HTML:
https://stackoverflow.com/questions/44525446/image-social-me...