You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How do I actually use a locally defined provider without contributing it to unpic? #169
I'm about 80% sure this is not an actual bug, but rather the fact that my knowledge of typescript is very patchy. Please bear with me :)
context: I wanted to add my own local provider to unpic. I have an endpoint that produces thumbnails on the fly, accepting just width and height from the url and rescaling the image. In prod, my images live on imagekit; this provider would handle things in the dev environment.
I've followed the instructions and made my own subclass of Operations, Options, generator and parser for Operations. I'm struggling with defining an URLExtractor<"local">, as the parametrized type is the ImageCdn union defined in unpic itself. I can't seem to be able to modify it via typescript module augmentation - I'm either using it incorrectly or there's something missing.
Would you please be able to add a minimal example of this to the documentation? Or add it here, and I'll happily update the docs :)
I've tried for a few hours to try and get around this limitation and defined my own set of CdnOperations and CdnOptions but this function requires the typeto be one of the hardcoded values inside types.ts which seems incredibly frustrating.
The docs mention following the contributing guide to implement a private transformer but this seems virtually impossible since a lot of the types that need to be configured are hard-coded into the library itself.
Activity
yacoob commentedon Feb 8, 2025
Judging by this documentation I can't add to a type alias via module augmentation. Which means I can't add to
ImageCdn. Am I reading things correctly?PoSayDone commentedon Apr 25, 2025
I'm also interested in this
lesofl commentedon Jan 11, 2026
Any update on this?
I've tried for a few hours to try and get around this limitation and defined my own set of
CdnOperationsandCdnOptionsbut this function requires the typeto be one of the hardcoded values insidetypes.tswhich seems incredibly frustrating.The docs mention following the contributing guide to implement a private transformer but this seems virtually impossible since a lot of the types that need to be configured are hard-coded into the library itself.
I am really looking for something simple that allows simple manipulation of the URL similar to one offered by NextJS which can be found here: https://nextjs.org/docs/app/api-reference/components/image#loader.