Skip to content

Commit

Permalink
fix: adding config to CLD_OPTIONS to avoid it being added to the DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
colbyfayock committed May 24, 2024
1 parent e491731 commit 528d69e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion next-cloudinary/src/components/CldImage/CldImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,25 @@ export type CldImageProps = Omit<ImageProps, 'src' | 'quality'> & ImageOptions &
const CldImage = forwardRef<HTMLImageElement, CldImageProps>(function CldImage(props, ref) {
let hasThrownError = false;

// Add props here that are intended to only be used for
// Cloudinary URL construction to avoid them being forwarded
// to the DOM

const CLD_OPTIONS = [
'assetType',
'config',
'deliveryType',
'preserveTransformations',
'strictTransformations',
'assetType',
];

// Loop through all of the props available on the transformation plugins and verify
// that we're not accientally applying the same prop twice

// We're also using those props to push into CLD_OPTIONS which helps us filter what
// props are applied to the underlaying Image component vs what's being sent
// to Cloudinary URL construction

transformationPlugins.forEach(({ props }: { props: Record<string, unknown> }) => {
const pluginProps = Object.keys(props);
pluginProps.forEach(prop => {
Expand Down

0 comments on commit 528d69e

Please sign in to comment.