Skip to content

Conversation

@LeonardoRick
Copy link
Contributor

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Expose the image element as its currently impossible to access it without a querySelector

@LeonardoRick LeonardoRick requested a review from danielroe as a code owner May 10, 2025 21:34
@LeonardoRick LeonardoRick changed the title expose image element on nuxtImg through defineExpose expose <img> element on nuxtImg through defineExpose May 10, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented May 10, 2025

Open in StackBlitz

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

commit: fb9d22d

@codecov-commenter
Copy link

codecov-commenter commented May 10, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
βœ… Project coverage is 7.06%. Comparing base (7efb6ef) to head (fb9d22d).

Files with missing lines Patch % Lines
src/runtime/components/NuxtImg.vue 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #1834      +/-   ##
========================================
+ Coverage   7.03%   7.06%   +0.02%     
========================================
  Files         77      77              
  Lines       3552    3554       +2     
  Branches     138     138              
========================================
+ Hits         250     251       +1     
- Misses      3254    3255       +1     
  Partials      48      48              

β˜” 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.

@LeonardoRick LeonardoRick force-pushed the expose-image-element branch from 1315a11 to 0c48f64 Compare May 10, 2025 21:38
Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

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

what do you want to do with the image element?

@LeonardoRick
Copy link
Contributor Author

LeonardoRick commented May 11, 2025

@danielroe In my specific case I want to rotate the image in realtime. The rotate modifier was not working as it seems to not be suited for realtime updates. I see some people also wanting to access it.

My solution for now is using querySelector('img') but would be nice to access the element directly.

  () => {
    if (!self.value) return;
    const img = self.value.querySelector('img');
    if (!img) return;
    img.style.setProperty('--background-rotation', `${rotate}deg`);
  }

@LeonardoRick LeonardoRick force-pushed the expose-image-element branch from 07e97d7 to 5d5e4bc Compare May 20, 2025 21:42
@LeonardoRick LeonardoRick force-pushed the expose-image-element branch from 5d5e4bc to cb76488 Compare May 21, 2025 21:58
@LeonardoRick
Copy link
Contributor Author

Hey! Any reason not to approve this one?

@vercel
Copy link

vercel bot commented Aug 5, 2025

@LeonardoRick is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@danielroe danielroe changed the title expose <img> element on nuxtImg through defineExpose feat(nuxt-img): expose <img> element Oct 28, 2025
@danielroe danielroe merged commit 6679aa7 into nuxt:main Oct 28, 2025
7 checks passed
@github-actions github-actions bot mentioned this pull request Oct 28, 2025
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.

3 participants