Dynamic Images are not displaying or rendering #38581
toddcoulson
started this conversation in
Community
Replies: 1 comment
-
Hi Todd, you can either supply I've also included two options for you for filtering the images by directory directly within from GraphQL. import React from 'react'
import { graphql } from 'gatsby'
import { GatsbyImage, getImage } from 'gatsby-plugin-image'
const Sponsors = ({ data }) => (
<div>
{data.allFile.nodes.map((sponsor) => (
<>
<GatsbyImage image={getImage(sponsor.childImageSharp)} />
<GatsbyImage image={sponsor.childImageSharp.gatsbyImageData} />
</>
))}
</div>
)
export default Sponsors
export const query = graphql`
query {
allFile(
filter: {
relativeDirectory: { eq: "sponsors" }
relativePath: { glob: "sponsors/*.jpg" }
}
sort: { name: ASC }
) {
nodes {
childImageSharp {
gatsbyImageData
}
}
}
}
` Please refer to the documentation for more information on that topic: https://www.gatsbyjs.com/docs/how-to/images-and-media/using-gatsby-plugin-image/#dynamic-images |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am a newb with Gatsby, but have been building React apps professionally, for point of reference. I have the following class:
Pardon me for the code dump, but the query at the bottom of the page displays the results I want in graphiql. I am also getting the results in my console logs. However, you can see the javascript I have to dynamically place images on the page in a loop in callImages method. I am trying to place it with either a getImage method or a gatsby image data, but neither one is displaying any images on the screen. Does anyone see anything that may not be in line with the proper gatsby technique?
Beta Was this translation helpful? Give feedback.
All reactions