An image, an image! My Kingdom for a header image!
King Richard III, probably
Uses the wonderful npm package open-graph-scraper to fetch some image from a given URL.
I have a demo server running at
URL_TO_FETCH_IMAGES_FROM must be url encoded.
For example, the header image to this repo can be fetched like this: https://image.letterq.org/https%3A%2F%2Fgithub.com%2Fqcasey%2Ffetch-image-proxy
Docker Image is built automatically to run your own server.
The package prefers open graph images, but will fall back to the first inline
This API 302 redirects requests to the found image, so you can include it (with an errorBuilder) in components like:
Responses are in the ~1-3 second range, depending on a number of factors. You can put an image cache like Cloudflare in front of this API to drastically improve response times after the first fetch.
What works well
URLs with premade open graph images
URLs with img tags in the html
What doesn’t work
405when you didn’t URL encode
404when there aren’t any images to fetch from the URL
302redirect to the found image