Replace URL delegation with the Fallback system
mainVersion 4 removes the recursive URL delegation system (the recursive option). Instead, use the fallback property to explicitly define which provider should handle a URL if it is not recognized as a known CDN URL.
This is useful for handling user-provided URLs or ensuring framework-specific optimizers (like nextjs) are used when a source URL is unrecognized.
// Use a fallback provider when a URL isn't recognized
transformUrl(
{
url: "https://example.com/image.jpg",
width: 1200,
fallback: "nextjs",
},
{},
{
// optional configuration for the fallback provider
}
);