Expose DPR/density to provider context for preset-based image providers #2116
Xanndr-exe
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
While implementing a custom Nuxt Image provider, I ran into a limitation related to DPR handling.
Nuxt Image automatically multiplies width and height modifiers by dpr, which works great for providers that accept numeric resize parameters. However, some providers operate in preset-only mode, where you pass a named transformation such as sm, md, lg, etc., and the actual dimensions are defined on the CDN side. In this case, width and height cannot be dynamically scaled by DPR, and all densities effectively resolve to the same preset.
This makes it difficult to generate density-specific preset URLs like sm_1x, sm_2x, etc.
Since getImage() runs per render, maybe it might be useful if the current DPR were available in the image context so the provider could decide how to map density (numeric scaling vs preset mapping) instead of relying on automatic width/height multiplication.
I’m wondering whether exposing the current DPR (density) to the provider context would help solve this, or whether this is even necessary, and there is a recommended workaround for preset-based providers.
Beta Was this translation helpful? Give feedback.
All reactions