Limit the transformation images variants
Hello team,
I recently suggested cloudflare transformation images to client in order to serve responsive images where images are hosted elsewhere. Even though the pricing is cheap, client had this concern
If we are getting charged per unique transformation, for example w=200, but lets suppose some bad actor know this url and can just write a script to run a for loop which will request image based on width from 1 to any number.
I didn't have any answer to that. So came here to ask.
Is there a way to pre define the transformation variant and if asked for other variants, i would just return with duplicate variant
3 Replies
I'm also interested in this 🙋♂️
You can use Image Transformations via Workers to implement specific presets and control what transformations can be done: https://developers.cloudflare.com/images/transform-images/transform-via-workers/
Cloudflare Docs
Transform via Workers · Cloudflare Image Optimization docs
Using Cloudflare Workers to transform with a custom URL scheme gives you powerful programmatic control over every image request.
yeah found this later. Using workers for this use case. thanks