react-photo-gallery icon indicating copy to clipboard operation
react-photo-gallery copied to clipboard

Does not work with local image files

Open christocarr opened this issue 4 years ago • 7 comments

christocarr avatar May 11 '20 10:05 christocarr

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

christocarr avatar May 11 '20 10:05 christocarr

Did you solve the issue

kannanseeni avatar May 12 '20 10:05 kannanseeni

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

christocarr avatar May 13 '20 07:05 christocarr

` 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 } ];

<Gallery photos={photos} />;`

check above code, it will help you

kannanseeni avatar May 13 '20 20:05 kannanseeni

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.

christocarr avatar May 14 '20 09:05 christocarr

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?

douglasrcjames avatar Nov 19 '20 00:11 douglasrcjames

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

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

Works for me ;)

alexdev006 avatar Jan 06 '21 15:01 alexdev006