Skip to content

feat(provider): Add umbraco image provider#2165

Open
jemomi wants to merge 16 commits intonuxt:mainfrom
jemomi:feature/umbraco-image-provider
Open

feat(provider): Add umbraco image provider#2165
jemomi wants to merge 16 commits intonuxt:mainfrom
jemomi:feature/umbraco-image-provider

Conversation

@jemomi
Copy link

@jemomi jemomi commented Mar 13, 2026

🔗 Linked issue

Resolves discussion: #1629

📚 Description

As requested in aforementioned discussion. Here is provider for Umbraco images.
Use cases in regards to "generate on demand" images are implemented. But currently no support is or will be made for set crop definitions (Because i currently do not have a setup that uses set crops).

Provider could potentially be renamed to "imageSharp", but since I expect most use cases will be from umbraco, I kept it as "umbracoImage"

The image used for testing, is one that is currently present on the frontpage of umbraco's website. Full disclosure, Umbraco has nothing to do with the development of this provider, and har not been informed that an image from their page is being used for these tests. So it might disappear. But I will try and get into contact with them to see if I can get a stable image source from them.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 13, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/image@2165

commit: c74fcbb

@codecov-commenter
Copy link

codecov-commenter commented Mar 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 32.52%. Comparing base (5be826f) to head (c74fcbb).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2165   +/-   ##
=======================================
  Coverage   32.52%   32.52%           
=======================================
  Files           7        7           
  Lines         372      372           
  Branches      131      131           
=======================================
  Hits          121      121           
  Misses        194      194           
  Partials       57       57           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jemomi jemomi changed the title Feature/umbraco image provider feat(provider): Add umbraco image provider Mar 15, 2026
@jemomi jemomi marked this pull request as ready for review March 19, 2026 19:35
@jemomi jemomi requested a review from danielroe as a code owner March 19, 2026 19:35
@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

📝 Walkthrough

Walkthrough

A new Umbraco image provider is added to the Nuxt Image module. The implementation includes a runtime provider that maps Nuxt Image modifiers to Umbraco/ImageSharp query parameters, provider registration in the built-in providers list, playground configuration and examples, comprehensive documentation explaining the provider's usage and modifier mappings, and corresponding unit/snapshot tests. All changes are additions with no modifications to existing code.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(provider): Add umbraco image provider' accurately and concisely summarizes the main change—adding a new Umbraco image provider to the codebase.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose, use cases, naming rationale, and known limitations of the new Umbraco image provider being added.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can approve the review once all CodeRabbit's comments are resolved.

Enable the reviews.request_changes_workflow setting to automatically approve the review once all CodeRabbit's comments are resolved.

Copy link

@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: 4

🧹 Nitpick comments (2)
test/providers.ts (1)

43-43: Consider adding fixture cases for Umbraco-specific modifiers in this unit matrix.

focalPointXY (rxy), quality, sampler, and anchorPosition mappings are not covered here, so regressions in those mappings rely mainly on e2e snapshots.

Also applies to: 86-86, 128-128, 170-170, 212-212, 254-254

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/providers.ts` at line 43, The test matrix entry using umbracoImage lacks
coverage for Umbraco-specific modifiers; add fixture cases that include
focalPointXY (rxy), quality, sampler, and anchorPosition to the unit test matrix
for the umbracoImage variants so mappings are validated individually. Locate the
umbracoImage test entries (symbol: umbracoImage) in test/providers.ts and
augment the matrix with separate cases covering rxy values, different quality
levels, explicit sampler names, and anchorPosition values mirroring the e2e
scenarios; ensure each new fixture asserts the expected mapped output so
regressions in the mapping functions are caught by unit tests.
src/runtime/providers/umbracoImage.ts (1)

20-21: defaultModifiers + defu is currently a no-op.

defaultModifiers is empty, so this merge adds overhead without changing behavior.

♻️ Optional simplification
-const defaultModifiers = {}
@@
-    const mergedModifiers = defu(normalizedModifiers, defaultModifiers)
-    const operations = operationsGenerator(mergedModifiers)
+    const operations = operationsGenerator(normalizedModifiers)

Also applies to: 40-41

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/runtime/providers/umbracoImage.ts` around lines 20 - 21, defaultModifiers
is an empty object so merging it with defu is a no-op — remove the unnecessary
merge: replace any defu(modifiers, defaultModifiers) usage with either the
incoming modifiers (or modifiers ?? {}) or supply actual meaningful default
values in defaultModifiers; also remove the now-unused defaultModifiers constant
and any unused defu import/usage (references: defaultModifiers, defu).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/content/3.providers/umbracoImage.md`:
- Line 185: The heading "HMAC protected image URLs" should use the hyphenated
adjective form; update the heading text (the line containing "HMAC protected
image URLs" / the "HMAC protected" phrase) to "HMAC-protected image URLs" so the
documentation uses correct grammar and style.
- Line 7: Replace the incorrect fork URL used in the Markdown link (the "to:
https://github.com/jemomi/nuxt-image/blob/main/src/runtime/providers/umbracoImage.ts"
reference) with the canonical repository path
"https://github.com/nuxt/image/blob/main/src/runtime/providers/umbracoImage.ts"
so the Source link in docs/content/3.providers/umbracoImage.md points to the
main project and avoids stale/broken references.

In `@playground/app/providers.ts`:
- Line 1405: Replace the external Umbraco image URLs used in the sample objects
(the src fields for the Umbraco sample images) with a stable, repo-controlled
static fixture image and ensure the sample objects point to that fixture; then
update test/e2e/__snapshots__/umbracoImage.json5 to match the new fixture
URL/data so E2E snapshot tests are not dependent on third-party hosts.

In `@src/runtime/providers/umbracoImage.ts`:
- Around line 31-41: In getImage, avoid assuming modifiers exists and don't
mutate the caller's object: default the parameter to an empty object (handle
undefined) and create a new local copy (e.g., mergedModifiers) before
adjustments; perform the 'contain' -> 'crop' remap on that local copy (not on
the incoming modifiers) and then pass mergedModifiers into operationsGenerator
and defu with defaultModifiers so the original modifiers remains unchanged and
no runtime error occurs when modifiers is omitted.

---

Nitpick comments:
In `@src/runtime/providers/umbracoImage.ts`:
- Around line 20-21: defaultModifiers is an empty object so merging it with defu
is a no-op — remove the unnecessary merge: replace any defu(modifiers,
defaultModifiers) usage with either the incoming modifiers (or modifiers ?? {})
or supply actual meaningful default values in defaultModifiers; also remove the
now-unused defaultModifiers constant and any unused defu import/usage
(references: defaultModifiers, defu).

In `@test/providers.ts`:
- Line 43: The test matrix entry using umbracoImage lacks coverage for
Umbraco-specific modifiers; add fixture cases that include focalPointXY (rxy),
quality, sampler, and anchorPosition to the unit test matrix for the
umbracoImage variants so mappings are validated individually. Locate the
umbracoImage test entries (symbol: umbracoImage) in test/providers.ts and
augment the matrix with separate cases covering rxy values, different quality
levels, explicit sampler names, and anchorPosition values mirroring the e2e
scenarios; ensure each new fixture asserts the expected mapped output so
regressions in the mapping functions are caught by unit tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5deee012-f6af-46d2-8282-c7fa75e37769

📥 Commits

Reviewing files that changed from the base of the PR and between 5be826f and c74fcbb.

📒 Files selected for processing (8)
  • docs/content/3.providers/umbracoImage.md
  • playground/app/providers.ts
  • playground/nuxt.config.ts
  • src/provider.ts
  • src/runtime/providers/umbracoImage.ts
  • test/e2e/__snapshots__/umbracoImage.json5
  • test/nuxt/providers.test.ts
  • test/providers.ts

links:
- label: Source
icon: i-simple-icons-github
to: https://github.com/jemomi/nuxt-image/blob/main/src/runtime/providers/umbracoImage.ts
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Point Source to the canonical repository path.

Line 7 currently links to a fork URL. Use the main project URL (https://github.com/nuxt/image/blob/main/src/runtime/providers/umbracoImage.ts) to avoid stale/broken references.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/content/3.providers/umbracoImage.md` at line 7, Replace the incorrect
fork URL used in the Markdown link (the "to:
https://github.com/jemomi/nuxt-image/blob/main/src/runtime/providers/umbracoImage.ts"
reference) with the canonical repository path
"https://github.com/nuxt/image/blob/main/src/runtime/providers/umbracoImage.ts"
so the Source link in docs/content/3.providers/umbracoImage.md points to the
main project and avoids stale/broken references.


Umbraco supports using set crops for images. These however, aren't currently supported.

### HMAC protected image URLs
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use hyphenated form: “HMAC-protected”.

Minor docs grammar fix on Line 185.

🧰 Tools
🪛 LanguageTool

[grammar] ~185-~185: Use a hyphen to join words.
Context: ...r, aren't currently supported. ### HMAC protected image URLs If your Umbraco se...

(QB_NEW_EN_HYPHEN)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/content/3.providers/umbracoImage.md` at line 185, The heading "HMAC
protected image URLs" should use the hyphenated adjective form; update the
heading text (the line containing "HMAC protected image URLs" / the "HMAC
protected" phrase) to "HMAC-protected image URLs" so the documentation uses
correct grammar and style.

name: 'umbracoImage',
samples: [
{
src: 'https://umbraco.com/media/hvjlhtfw/home-full-screen-4.png',
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Use a stable fixture source for samples to avoid flaky E2E snapshots.

These lines depend on a third-party image URL that may disappear, which can break snapshot-based tests unexpectedly. Prefer a repo-owned/static fixture (or other controlled asset) and update test/e2e/__snapshots__/umbracoImage.json5 accordingly.

Also applies to: 1412-1412, 1419-1419

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@playground/app/providers.ts` at line 1405, Replace the external Umbraco image
URLs used in the sample objects (the src fields for the Umbraco sample images)
with a stable, repo-controlled static fixture image and ensure the sample
objects point to that fixture; then update
test/e2e/__snapshots__/umbracoImage.json5 to match the new fixture URL/data so
E2E snapshot tests are not dependent on third-party hosts.

Comment on lines +31 to +41
getImage: (src, {
modifiers,
baseURL = '',
}) => {
// modifier.fit - 'contain' is remapped to use 'crop', since this is the value used by ImageSharp.
if (modifiers.fit === 'contain') {
modifiers.fit = 'crop'
}

const mergedModifiers = defu(modifiers, defaultModifiers)
const operations = operationsGenerator(mergedModifiers)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Handle optional modifiers safely and avoid mutating input.

Line 36 assumes modifiers is always defined, which can throw when getImage is called without modifiers. Line 37 also mutates caller-provided input.

🔧 Proposed fix
 export default defineProvider<UmbracoImageOptions>({
   getImage: (src, {
     modifiers,
     baseURL = '',
   }) => {
+    const normalizedModifiers = { ...(modifiers || {}) }
+
     // modifier.fit - 'contain' is remapped to use 'crop', since this is the value used by ImageSharp.
-    if (modifiers.fit === 'contain') {
-      modifiers.fit = 'crop'
+    if (normalizedModifiers.fit === 'contain') {
+      normalizedModifiers.fit = 'crop'
     }
 
-    const mergedModifiers = defu(modifiers, defaultModifiers)
+    const mergedModifiers = defu(normalizedModifiers, defaultModifiers)
     const operations = operationsGenerator(mergedModifiers)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
getImage: (src, {
modifiers,
baseURL = '',
}) => {
// modifier.fit - 'contain' is remapped to use 'crop', since this is the value used by ImageSharp.
if (modifiers.fit === 'contain') {
modifiers.fit = 'crop'
}
const mergedModifiers = defu(modifiers, defaultModifiers)
const operations = operationsGenerator(mergedModifiers)
getImage: (src, {
modifiers,
baseURL = '',
}) => {
const normalizedModifiers = { ...(modifiers || {}) }
// modifier.fit - 'contain' is remapped to use 'crop', since this is the value used by ImageSharp.
if (normalizedModifiers.fit === 'contain') {
normalizedModifiers.fit = 'crop'
}
const mergedModifiers = defu(normalizedModifiers, defaultModifiers)
const operations = operationsGenerator(mergedModifiers)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/runtime/providers/umbracoImage.ts` around lines 31 - 41, In getImage,
avoid assuming modifiers exists and don't mutate the caller's object: default
the parameter to an empty object (handle undefined) and create a new local copy
(e.g., mergedModifiers) before adjustments; perform the 'contain' -> 'crop'
remap on that local copy (not on the incoming modifiers) and then pass
mergedModifiers into operationsGenerator and defu with defaultModifiers so the
original modifiers remains unchanged and no runtime error occurs when modifiers
is omitted.

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