OriAmir / React-Responsive-Gallery

Simple and responsive gallery for react
45 stars 5 forks source link

Failed to load local images from folder #8

Closed AnushreeDhar closed 4 years ago

AnushreeDhar commented 4 years ago

I intend to use local images and not src from url.. is that a bug or will be taken up later?

OriAmir commented 4 years ago

hi @AnushreeDhar . I should implement and add that, you could also create a PR and send to me!

AnushreeDhar commented 4 years ago

sure let me know which branch to use thanks!

OriAmir commented 4 years ago

You could use the develop branch. I think that we miss the url-loader, file-loader plugins in the webpack

thanks for your help !

OriAmir commented 4 years ago

@AnushreeDhar Hi, I check that, I create a simple CRA, add local images and it seems like it works.

      <ResponsiveGallery
        images={[
          {
            src: require("./img.png"),
          },
          {
            src:
              "https://cdn.pixabay.com/photo/2017/03/23/13/23/stag-2168278_960_720.jpg",
          },...]/>

You can see in the image below that it's local image:

image

If you are not using CRA and you use webpack to config your project pls add file-loader plugin to your webpack.config file:

  {
        test: /\.(png|jpe?g|gif)$/i,
        use: [
          {
            loader: 'file-loader',
            options: {
              esModule: false,
            },
          },
        ],
      }

if you have any other question I will glad to help you.

AnushreeDhar commented 4 years ago

okay mine require isnt working i tried with src: ${pic1}, this worked! but thanks for your help

OriAmir commented 4 years ago

sure, if you have any other issue/suggestion pls contact me / open an issue,tnx!