vercel / satori

Enlightened library to convert HTML and CSS to SVG
https://og-playground.vercel.app
Mozilla Public License 2.0
11.14k stars 251 forks source link

Provide image fallbacks #403

Open JeroenReumkens opened 1 year ago

JeroenReumkens commented 1 year ago

Feature Request

Description

Hey! At Cal.com we are using Satori and Vercel OG to render quite a few dynamic images. There's however situations where there's an error because for example a users avatar throws an error, or a certain screenshot we make for all pages of our marketing site isn't screenshot properly and thus errors. If I'm correct whenever such an error occurs, this occurs during the parsing of the readable stream? Since I did try to wrap a try catch around the new ImageResponse, but that doesn't seem to be what causes the error.

So I'm wondering if there's a way to catch these errors, and then return a different fallback image. Or even better would be if this fallback image would be a default option of Satori / Vercel OG itself. This way we won't have broken images, but have a fallback image.

Thanks for this great library! ✌️

jeetiss commented 1 year ago

implement a fix in #404

it should allow to create image fallback

JeroenReumkens commented 1 year ago

Great work @jeetiss! Didn’t see that pr, only searched the issues apparently. Hopefully it gets merged soon!

Edit: oh it’s actually a new PR! Even better 🙏 Thanks for making a pr so fast!

shuding commented 1 year ago

Image fallback is a nice feature, since browsers already have that for decades!

Jackie1210 commented 1 year ago

good feature request!I will impl it recently @JeroenReumkens