cloudinary-community / netlify-plugin-cloudinary

Supercharge images on your Netlify site with Cloudinary!
https://netlify.cloudinary.dev/
MIT License
42 stars 18 forks source link

[Feature] Configurable Image Optimization Parametrs #52

Open akshay-ranganath opened 1 year ago

akshay-ranganath commented 1 year ago

Feature Request

Currently, image URLs are published with f_auto,q_auto. Consider adding option so that users can specify additional parameter like width, height, DPR. This settings could be applied in the netlify.toml file.

Describe the solution you'd like

Describe alternatives you've considered

Additional context

colbyfayock commented 1 year ago

@akshay-ranganath what type of granularity would you expect out of configuration of transformations? per image? would this be globally configurable? or perhaps a selector of sorts

borrowing an example from another plugin:

[[plugins]]
 package = "netlify-plugin-visual-diff"
 [plugins.inputs]
   ignoreSelector = "#today,.copyright"

   [[plugins.inputs.browser]]
     name = "chrome"
     width = 1024
     height = 768

   [[plugins.inputs.browser]]
     name = "firefox"
     width = 1920
     height = 1080

we see we can configure an input as an array of objects if we wanted to have some sort of selector-based configuration or something that we can target assets accurately

there's also an idea of borrowing Netlify's existing Large Media transformations API which is somewhat like ours, but allow someone to chain on transformations: https://docs.netlify.com/large-media/transform-images/ - if using the Netlify syntax, could help with migrations maybe?

one problem i potentially foresee with that though is if it changes the image in a way that prevents the page from working as expected, such as if one were to crop an image to a different aspect ratio that isn't what the HTML width and height conforms to, though this may simply be expected user risk and could happen even when hand-crafting this type of thing, though this wouldn't be apparently in development mode given this runs on build