I think that your issue appears due to the changing port between gatsby develop
(port 8000
) and gatsby build
(port 9000
). Since the requesting port has changed it causes the ERR_CONNECTION_REFUSED
because of the src
of the <img>
tag.
I would suggest using gatsby-image
for handling and bypassing that type of issues. Your code should look like this:
export const query = graphql`
query GetSingleHome($slug: String) {
galleryImage {
formats {
medium
childImageSharp {
fluid(maxWidth: 400, maxHeight: 250) {
...GatsbyImageSharpFluid
}
}
}
}
}
`
Note: I'm assuming that you've set properly the filesystem (gatsby-source-filesystem
) in order to allow Gatsby to parse and compile your images. If not, please configure it properly. Change the maxWidth
and maxHeight
as you wish.
Now, you can use:
<div className="image-grid">
{data.home.galleryImage.map((image, index, caption) => (
<div className="image-item" key={`${index}-cl`} class="imgcontt">
<Img fluid={image.formats.medium.childImageSharp.fluid} alt="hh" class="galleryimg" thumbnail/>
</div>
))
}
</div>
Managing images with gatsby-image
allowing you to create local GraphQL nodes for the images, avoiding that connection issues.
If you haven't set your filesystem:
{
resolve: `gatsby-source-filesystem`,
options: {
name: `pages`,
path: `${__dirname}/src/images/`, //path to your images
},
},
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…