Skip to content

Conversation

LeonardoRick
Copy link

πŸ”— 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
Copy link

pkg-pr-new bot commented May 10, 2025

Open in StackBlitz

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

commit: 5cc4a49

@codecov-commenter
Copy link

codecov-commenter commented May 10, 2025

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 53.48%. Comparing base (7e52488) to head (cb76488).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1834      +/-   ##
==========================================
+ Coverage   53.47%   53.48%   +0.01%     
==========================================
  Files          79       79              
  Lines        3755     3756       +1     
  Branches      377      377              
==========================================
+ Hits         2008     2009       +1     
  Misses       1716     1716              
  Partials       31       31              

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

Hey! Any reason not to approve this one?

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.

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