The Tweet example you posted above showed a Twitter Card. Those work with a single, static image attached to a web page.
If you want to write code which enables anyone to choose an image from your site and Tweet it, you’ll need to have logic on the page which identifies which image a user has chosen, then upload it to Twitter on the backend, and have your own Tweet function and compose box which creates a new Tweet with the image attached. That will not look the same as the example Tweet you showed above.