Skip to content

Conversation

@aka-sacci-ccr
Copy link
Contributor

@aka-sacci-ccr aka-sacci-ccr commented Nov 17, 2025

What is this Contribution About?

Please provide a brief description of the changes or enhancements you are proposing in this pull request.

Issue Link

Please link to the relevant issue that this pull request addresses:

Loom Video

Record a quick screencast describing your changes to help the team understand and review your contribution. This will greatly assist in the review process.

Demonstration Link

Provide a link to a branch or environment where this pull request can be tested and seen in action.

Summary by CodeRabbit

  • New Features
    • Per-instance toggle to disable automatic image optimization: Image and Picture components now accept a disableims flag so you can opt out of optimization for individual images.
    • Preload/link hints, source set generation, and server-side image parameter handling now respect this flag for accurate loading and hinting.

@github-actions
Copy link
Contributor

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 0.133.5 update
  • 🎉 for Minor 0.134.0 update
  • 🚀 for Major 1.0.0 update

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 17, 2025

Walkthrough

Adds a new boolean flag disableims that flows through Picture and Image props, Picture context, loader params, and image optimization utilities; when set the flag is passed to URL/building helpers and causes disableims=true to be included in optimization requests.

Changes

Cohort / File(s) Summary
Image component & utilities
website/components/Image.tsx
Added disableims?: boolean to Image props and forwarded it into getSrcSet, getEarlyHintFromSrcProps, and final src/srcSet/early-hint/link generation; updated function signatures to accept disableims and append disableims=true to optimization URL when set.
Picture / Source flow and context
website/components/Picture.tsx
Added disableims?: boolean to Picture props and Context, included it in the Context provider value (memo deps), and propagated disableims from Picture/Context into Source rendering, getSrcSet, and early-hint generation (server path).
Loader parameter parsing
website/loaders/image.ts
parseParams now accepts disableims and returns a boolean disableims field on the parsed Props object.
Image engine params
website/utils/image/engine.ts
Added optional disableims?: boolean to the Params interface used by the image engine resolution API.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Picture
    participant Image
    participant Source
    participant Utils as getSrcSet / getOptimizedMediaUrl

    Note over Picture,Image: Prop flow includes `disableims?: boolean`
    Picture->>Source: render (passes disableims via Context/props)
    Source->>Image: render <disableims>
    Image->>Utils: getSrcSet(src, sizes, ..., disableims)
    Utils->>Utils: build optimized URL (append ?disableims=true if set)
    Utils-->>Image: srcSet (with URLs reflecting disableims)
    Image-->>Browser: render <img src/srcSet> and possibly preload/link hints
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Review threading of disableims through Picture Context → Source → Image → utilities.
  • Verify function signature updates (types/overloads) and no callsites left unmodified.
  • Confirm loader parsing and engine Params addition correctly treat disableims as boolean.

Possibly related PRs

Suggested reviewers

  • guitavano

Poem

🐰 I hop through props and context deep,
A tiny flag I softly keep,
"disableims" I whisper true,
URLs change color in my view,
A rabbit's wink — optimization sleeps. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is entirely a template with placeholder content and no actual information filled in about the changes, objectives, or testing. Fill in the template sections with actual details: describe the disableims flag functionality, link the relevant issue, provide a Loom video or demonstration link showing the changes in action.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(image): added optional disable optimization' clearly describes the main change: adding an optional flag to disable image optimization across Image, Picture, and related utilities.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-disableImageOptimization

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
website/components/Image.tsx (1)

107-148: Backend does not handle the disableims parameter—the feature is non-functional.

The frontend correctly appends disableims=true to the URL (line 148), but the backend loader:

  • Props type (website/utils/image/engine.ts) does not include a field for this parameter
  • parseParams function (website/loaders/image.ts) only extracts src, width, height, fit, qualitydisableims is silently ignored

This means the disableImageOptimization flag has no effect; all images are always optimized regardless of this setting.

Required fixes:

  1. Add disableImageOptimization?: boolean to the Props interface
  2. Extract and pass this parameter through parseParams
  3. Implement logic in the image engines to respect this flag
🧹 Nitpick comments (2)
website/components/Picture.tsx (2)

13-21: Consider adding JSDoc documentation for consistency.

The disableImageOptimization field is missing a JSDoc comment. While the name is self-explanatory, adding documentation would be consistent with the prop definitions in other parts of the codebase.

Apply this diff to add documentation:

 interface Context {
   preload?: boolean;
+  /** @description Disable image optimization */
   disableImageOptimization?: boolean;
 }

101-105: Consider adding JSDoc documentation.

Similar to the Context interface, consider adding a JSDoc comment to document the disableImageOptimization prop, consistent with how it's documented in Image.tsx (line 29).

Apply this diff:

 type Props = Omit<JSX.IntrinsicElements["picture"], "preload"> & {
   children: ComponentChildren;
   preload?: boolean;
+  /** @description Disable image optimization */
   disableImageOptimization?: boolean;
 };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b1a4a5 and b5935f9.

📒 Files selected for processing (2)
  • website/components/Image.tsx (10 hunks)
  • website/components/Picture.tsx (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
website/components/Picture.tsx (1)
website/components/Image.tsx (2)
  • SetEarlyHint (11-11)
  • Props (12-32)
🔇 Additional comments (6)
website/components/Image.tsx (4)

29-30: LGTM: Clear prop definition.

The new prop is properly typed and documented, consistent with other prop definitions in the interface.


59-59: LGTM: Consistent type definition.

The field is properly added to the optimization options interface.


167-197: LGTM: Proper parameter propagation.

The disableImageOptimization parameter is correctly added to the function signature and properly passed to getOptimizedMediaUrl.


199-227: LGTM: Early hints respect the disable flag.

The disableImageOptimization parameter is properly added to the function signature and correctly propagated to getOptimizedMediaUrl, ensuring early hints also respect the optimization flag.

website/components/Picture.tsx (2)

39-74: LGTM: Proper Context usage and propagation.

The disableImageOptimization flag is correctly read from Context and properly passed to both getSrcSet and getEarlyHintFromSrcProps, ensuring consistent behavior throughout the Source component.


107-122: LGTM: Correct useMemo implementation.

The disableImageOptimization prop is properly destructured, included in the memoized value, and correctly added to the dependency array. This ensures the Context value updates appropriately when the prop changes.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
website/loaders/image.ts (1)

23-37: All four image engines must be updated to handle the disableims flag.

Verification confirms the original concern: while disableims is now parsed and included in the Params interface, none of the engine implementations (cloudflare, wasm, deco, passThrough) actually use it. The parameter is propagated to engine.resolve() but never acted upon, meaning the feature to skip optimization when disableims: true is set won't work.

  • Cloudflare engine (website/utils/image/engines/cloudflare/engine.ts): Destructures params but doesn't check disableims
  • Wasm engine (website/utils/image/engines/wasm/engine.ts): Destructures params but doesn't check disableims
  • Deco engine (website/utils/image/engines/deco/engine.ts): urlFromParams doesn't check disableims
  • PassThrough engine (website/utils/image/engines/passThrough/engine.ts): Only destructures src, completely ignores disableims

Each engine needs to check the disableims flag and skip its optimization logic when true.

🧹 Nitpick comments (1)
website/loaders/image.ts (1)

36-36: Simplify the boolean conversion.

The ternary disableims ? true : false is redundant and can be simplified.

Apply this diff:

-    disableims: disableims ? true : false,
+    disableims: Boolean(disableims),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b5935f9 and 83190bb.

📒 Files selected for processing (4)
  • website/components/Image.tsx (10 hunks)
  • website/components/Picture.tsx (5 hunks)
  • website/loaders/image.ts (2 hunks)
  • website/utils/image/engine.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • website/components/Picture.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
website/loaders/image.ts (1)
website/components/Image.tsx (1)
  • Props (12-32)
🔇 Additional comments (6)
website/utils/image/engine.ts (1)

7-7: LGTM! Clean API extension.

The optional disableims property is properly typed and extends the public API surface for all engine implementations.

website/components/Image.tsx (5)

29-30: LGTM! Clear documentation added.

The disableims property is properly documented and typed as an optional boolean.


107-165: LGTM! Proper propagation through optimization pipeline.

The disableims flag is correctly:

  1. Destructured from options (line 108)
  2. Added to query parameters when truthy (line 148)
  3. Propagated to both the Azion and standard optimization URL paths

This ensures the flag reaches the image loader for downstream handling.


167-197: LGTM! Consistent parameter threading.

The disableims parameter is properly added to getSrcSet signature and correctly forwarded to getOptimizedMediaUrl for each factor in the srcset generation.


199-227: LGTM! Early hints support the new flag.

The disableims parameter is correctly added to getEarlyHintFromSrcProps and properly propagated to getOptimizedMediaUrl, ensuring preload hints respect the optimization flag.


229-295: LGTM! Component properly wires the flag.

The Image component correctly propagates props.disableims to both:

  1. getSrcSet for srcset generation (line 246)
  2. getEarlyHintFromSrcProps for preload hints (line 272)

This ensures the flag flows through all optimization paths.

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

Successfully merging this pull request may close these issues.

2 participants