neptunian / react-photo-gallery

React Photo Gallery
http://neptunian.github.io/react-photo-gallery/
Other
1.95k stars 307 forks source link

Does not work with local image files #172

Open christocarr opened 4 years ago

christocarr commented 4 years ago

Needs the require method to get the src of the image.

kannanseeni commented 4 years ago

Did you solve the issue

christocarr commented 4 years ago

No, unable to. Not sure what I'm doing wrong.

kannanseeni commented 4 years ago

` import Bigimage from "../images/bigimage.jpg" const photos = [ { src: '${Bigimage}', width: 4, height: 3 }, { src: 'http://example.com/example/img2.jpg', width: 1, height: 1 } ];

;`

check above code, it will help you

christocarr commented 4 years ago

I've used require like so const photos = [ { src: require ('../images/image.jpg'), width: 4, height: 3 } ] which works but cannot use srcSet and I don't want to import all of my local images as I have a lot.

douglasrcjames commented 3 years ago

require() is used by webpack which is used in my React.js app (create-create-app), and your code looks like it would work, what's the issue here?

alexdev006 commented 3 years ago

Hi, import bigImage from "../images/bigImage.jpg"

const photos = [{src:bigImage, width:4, height: 3 }, ....]

Works for me ;)