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

feat: support placeholder #477

Merged
merged 3 commits into from
Jun 21, 2022
Merged

feat: support placeholder #477

merged 3 commits into from
Jun 21, 2022

Conversation

treboryx
Copy link
Contributor

A starting point to resolve #189

Example added on the playground app.

Suggestions and/or contributions by fellow Nuxters would be appreciated!

@pi0 pi0 added the enhancement New feature or request label Jun 20, 2022
created () {
mounted () {
if (this.placeholder) {
this.image = this.placeholder
Copy link
Member

Choose a reason for hiding this comment

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

This is a nice start but also means on initial hydration, actual images only start loading when the whole JS bundle is loaded and hydration happens. We can enhance it later with a head script doing the same and hydrating from a data- attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose hydrating from a data atrribute would make a great addition for lazy loading images.

@codecov-commenter
Copy link

codecov-commenter commented Jun 21, 2022

Codecov Report

Merging #477 (816202a) into main (94625ce) will decrease coverage by 0.40%.
The diff coverage is 28.57%.

@@            Coverage Diff             @@
##             main     #477      +/-   ##
==========================================
- Coverage   58.95%   58.55%   -0.41%     
==========================================
  Files          34       34              
  Lines         709      719      +10     
  Branches      236      238       +2     
==========================================
+ Hits          418      421       +3     
- Misses        284      291       +7     
  Partials        7        7              
Impacted Files Coverage Δ
src/runtime/components/image.mixin.ts 81.81% <ø> (ø)
src/runtime/components/nuxt-img.vue 60.00% <28.57%> (-10.00%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94625ce...816202a. Read the comment docs.

@pi0
Copy link
Member

pi0 commented Jun 21, 2022

Thanks for working on this. I've pushed few improvements to directly use <NuxtImg placeholder> and auto generate URL.

@pi0 pi0 merged commit fc7e3d5 into nuxt:main Jun 21, 2022
@pi0 pi0 mentioned this pull request Jun 21, 2022
procrates pushed a commit to procrates/nuxt-image that referenced this pull request Feb 21, 2023
@STY1997
Copy link

STY1997 commented May 15, 2024

Hi, It seems that the placeholder does not work for cloud providers? I am using Hygraph as the image provider and I get a crashed image icon when loading the image.
Screenshot 2024-05-15 101608
Screenshot 2024-05-15 101702

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Placeholder support
4 participants