nuxt / nuxt/image

nuxt-img + vanilla-lazyload

Open
#741 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

upstream
Dominant language
TypeScript
Stars
1.5k
Forks
331
Avg merge
19h 52m
Merged PRs (30d)
9

Description

ERROR 1

Using <img tag it works. Using <nuxt-img tag instead, it doesn't work.

error: 500. Input must be a string (received undefined: undefined)

  1. with module v. 0.7 it works (for Nuxt v.2).
  2. with this version 1.x (for Nuxt v.3) it does not work because the module must have the src parameter already set. If in fact I use a combination of src + data-src the module works. However, in this way, I have to call two images.

Reproduction: https://stackblitz.com/edit/github-uv7ped?file=components/myimg.vue

ERROR 2

(related to the first ): <nuxt-picture with class="lazy" doen't work.

This works

<nuxt-img  
        src="/images/1x1.png"  
        :data-src="src"
        class="lazy shadow-md"
 />

This not

<figure>
	<nuxt-picture  
          src="/images/1x1.png"
          :data-src="src"
          :imgAttrs="{class:'lazy shadow-md w-full h-auto'}"
      	/>
      	<div class="flex justify-center">
      		<figcaption class="textdida">
        		<span>{{textdida }}</span>
      		</figcaption>
      	</div>
    	</figure>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz reproduction, especially components/myimg.vue, and compare the working nuxt-img example with the failing nuxt-img and nuxt-picture cases. Trace how src, data-src, and imgAttrs are passed to the components; done means lazy loading works without requiring a duplicate image source and both reported errors are resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxtjs, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.