Skip to content

fix: incorrect preload link for multiple densities #1851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

raggesilver
Copy link

NuxtImg did not add correct preload links for images that had multiple densities but only one size which caused the preload tag to load 1x images for devices with 2x pixel ratio. That is now fixed.

🔗 Linked issue

Resolves #1850

❓ 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

Do not require both sizes and densities to be set to generate imagesrcset. Take each of them into account.

NuxtImg did not add correct preload links for images that had multiple densities but only one size which caused the preload tag to load 1x images for devices with 2x pixel ratio. That is now fixed.
@raggesilver raggesilver requested a review from danielroe as a code owner May 25, 2025 02:51
@raggesilver raggesilver changed the title Fix #1850 fix: incorrect preload link for multiple densities May 25, 2025
Copy link

pkg-pr-new bot commented May 25, 2025

Open in StackBlitz

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

commit: 4529248

@codecov-commenter
Copy link

codecov-commenter commented May 25, 2025

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Project coverage is 53.51%. Comparing base (7e52488) to head (4529248).

Files with missing lines Patch % Lines
src/runtime/components/NuxtImg.vue 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1851      +/-   ##
==========================================
+ Coverage   53.47%   53.51%   +0.04%     
==========================================
  Files          79       79              
  Lines        3755     3752       -3     
  Branches      377      377              
==========================================
  Hits         2008     2008              
+ Misses       1716     1713       -3     
  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.

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.

Incorrect preload links for single size, multiple densities images
2 participants