https://580157013239-us-east-1-chromeless.s3.amazonaws.com/thread-shareables/aae45255ef.png
If you [View Source] any forums post on IH, and look at the meta tags for twitter:image , you will notice that social share images are generated dynamically!
Talk about:
Super cool feature, I'm extremely jealous!
Any LAMP-stack hackers have any ideas on how they'd go about replicating this? :) I found some PHP functions for creating images (https://stackoverflow.com/questions/901201/create-a-dynamic-png-image) but I'm wondering if anyone else has any alternate approaches to re-creating this awesome feature!
I did this for all the jobs on https://willrobotstakemyjob.com/
I think it really helped drive social media sharing on peoples timelines.
It's a pretty simple process, I have a private URL that is the HTML of the image for the job I want to share.
Then when some one requests the share image for the job, I check to see if the image was generated already, and if not I use headless chrome to grab the private URL for the job image page and save it to disk, then return the image from disk.
Edit: I used this package https://github.com/spatie/browsershot
Is it quick enough to do this? Been wanting to do this for something I work on but there are millions of possible images each with a possible 3000+ overlays depending on context so pre-generating would be insane. PhantomJS was too slow to do this per-request but if headless chrome is good enough I might be able to revisit.
It depends on how big and complex what you're generating is, but working pretty fast for me. Also, does depend on how big your server is, I'm running on a 2GB server.
I'm not pre-generating the images, there was nearly 800 jobs so I could have done it, but it was fast enough to do on request one time.
I save the image to disk so future requests are really fast.
It's also easy to clear the cache and force the images to be re-generated if the design changes.
Ok that sounds cool then. It’s notging very complex, just a photo with an icon and a name so I don’t think that’ll be too heavy. Planning to save after generating but most may only ever be shared once so it needs to work first time too. I’ll give it a try, thanks!
Cool! Let me know if you run into any issues.
It really is awesome!
I cant remember who, but a couple of weeks ago I saw someone created this as a service. I am going to find it.
edit: Found it.
https://www.imageee.com/ <-- The product.
https://twitter.com/thomaspetracco/status/942019856437731329 <-- Creator explaining in a tweet thread.
https://www.thomaspetracco.com/blog/why-and-how-i-created-imageee.com <--- Explanation in a blog.
Awesome. Yes, I was going to say, this feature could totally be a SAAS and I would pay for it, provided it was significantly easier to setup than doing it manually :)
Generating social shares is one of my personal most "wasted" uses of time. I feel like it should be automated, yet I do it manually. Ugh!
was also thinking about doing this as a Saas :D
What Mubashar described is pretty much the whole approach. There is also a blog by Peiter Levels on this - https://levels.io/phantomjs-social-media-share-pictures/.
That is a super cool feature! I never noticed because I don't really share things on social media, but I am sure that it makes a huge difference in making the posts more attractive to would be link clickers.
Right! I myself wondered how long it took me to notice! I've seen forum posts shared on Twitter for a while, but the share images seemed so "crisp" that I must have assumed they were hand-selected.
This comment was deleted 7 years ago