Skip to content
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

fix: nuxtpicture placeholder #1396

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

Conversation

acvigue
Copy link

@acvigue acvigue commented Jul 2, 2024

Closes #1160.

Adds placeholder behavior to NuxtPicture by initially setting the img element's src tag to the placeholder, waiting for the main src to load, and then showing the image.

@acvigue acvigue requested a review from danielroe as a code owner July 2, 2024 23:18
@codecov-commenter
Copy link

codecov-commenter commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 94.33962% with 3 lines in your changes missing coverage. Please review.

Project coverage is 62.44%. Comparing base (4efdc0b) to head (b0a6bb3).

Files Patch % Lines
src/runtime/components/_base.ts 89.28% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1396      +/-   ##
==========================================
+ Coverage   62.20%   62.44%   +0.23%     
==========================================
  Files          79       79              
  Lines        3593     3605      +12     
  Branches      391      401      +10     
==========================================
+ Hits         2235     2251      +16     
+ Misses       1328     1324       -4     
  Partials       30       30              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +138 to +140
if (mainSrc.value.sizes) img.sizes = mainSrc.value.sizes
if (mainSrc.value.srcset) img.srcset = mainSrc.value.srcset
if (mainSrc.value.src) img.src = mainSrc.value.src
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit worried that we end up loading more images than necessary. So, mainSrc will load, but then if there is another src that better suits browser needs (e.g. avif/webp), this will swap in, and we will have downloaded twice as much image data as we need.

do you have any ideas for resolving that? maybe using a picture element as placeholder instead?

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.

Placeholder for NuxtPicture
4 participants