react-photo-gallery
react-photo-gallery copied to clipboard
Does not work with local image files
Needs the require
method to get the src
of the image.
Did you solve the issue
No, unable to. Not sure what I'm doing wrong.
` 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
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.
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?
Hi,
import bigImage from "../images/bigImage.jpg"
const photos = [{src:bigImage, width:4, height: 3 }, ....]
Works for me ;)