nuxt / nuxt/image

How i can create a dynamic image gallery?

Open
#677 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hello! I'm trying to create a portfolio that imports all images from a specific folder, which is ~/static/images
How can i do that? i have this code:

<template>
    <div class="columns is-multiline">
        <nuxt-img
            v-for="image in images"
            :src="image"
        />
    </div>
</template>

<script>
export default {
    name: 'imageGallery',
    computed: {
      images () {
        const path = require.context('~/static/images', false, /\.jpg$/)
        return path.keys().map(path)
      }
    }
  }
</script>

and the image placehodlers appears, but none of the image are loaded.
console:

error

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

Reproduce the gallery using the ~/static/images folder and the NuxtImg component with the require.context setup shown in the issue. Start by checking the reported browser-console error and whether the generated image paths resolve. Done means the images from the folder load in the gallery without placeholder errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nuxtjs
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.