image icon indicating copy to clipboard operation
image copied to clipboard

fix: double loads of the original image when placeholder true

Open amrelbialy opened this issue 2 months ago โ€ข 5 comments

๐Ÿ”— Linked issue

resolves #1683

โ“ Fix

  • [ ] ๐Ÿ“– Documentation (updates to the documentation or readme)
  • [x] ๐Ÿž 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 Resolved an issue where images could load more than once in the NuxtImg component. Previously, when a placeholder image was in use, it triggered a new image load even though the main image had already started loading. The update ensures that if a placeholder is already handled, we avoid loading the image again. This change prevents duplicate network requests and avoids unnecessary load events. By removing the preload using new image() instance and adding onLoad to imgAttrs, and using vue reactive to handle the update when placeholderLoaded is true

amrelbialy avatar Oct 14 '25 15:10 amrelbialy

Open in StackBlitz

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

commit: 0b184f6

pkg-pr-new[bot] avatar Oct 14 '25 15:10 pkg-pr-new[bot]

Hi @danielroe Can we have a look at this fix please, it's really needed on our side. Thanks in advance for the feedback!

Aurelien-GH avatar Oct 27 '25 06:10 Aurelien-GH

would you be able to add a regression test case in ssr.test.ts to reproduce the bug and make sure it doesn't happen again? ๐Ÿ™

danielroe avatar Nov 04 '25 16:11 danielroe

@danielroe added

amrelbialy avatar Nov 06 '25 12:11 amrelbialy

Hey @danielroe, any updates?

amrelbialy avatar Dec 10 '25 08:12 amrelbialy