Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imageTransformDefaults; does not work for array configurations #14

Open
mohib-a-wasay-sweetgreen opened this issue Aug 26, 2021 · 1 comment

Comments

@mohib-a-wasay-sweetgreen

Thank you for the great work for this very helpful library.

Issue

compileImageTransforms do not support defaultTransform for array configs Check the following link

export const compileImageTransforms = (
  transform: ImageTransform | ImageTransform[],
  defaultTransform?: ImageTransform,
) => {
  const compiledTransform = Array.isArray(transform)
    ? transform.map(compileImageTransform).join('/')
    : compileImageTransform({ ...defaultTransform, ...transform })

  return compiledTransform ? `/${compiledTransform}` : ''
}
@marnusw
Copy link
Owner

marnusw commented Aug 26, 2021

That is correct. This was a design decision, because supplying multiple transforms is a complex case and the library should not assume which transform it should augment with the defaults.

My suggestion is to export your default tranforms object from the file where you initialise this library, and then spread that onto the transform in the array where you'd like them to apply.

If you have a reasonable idea how this could be supported by this library that obviates the above concern we can certainly discuss it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants