I would like to load all images in a certain folder (e.g. assets/team/) and use them through the gatsby-image plugin.
I currently have it working for 1 single file with this query:
export const query = graphql`
query BlurUpQuery {
heroAssets: imageSharp(id: { regex: "/testImage/" }) {
sizes(maxWidth: 600) {
...GatsbyImageSharpSizes_tracedSVG
}
}
}
`
which returns sizes for this asset. Is it possible to grab all assets in a certain folder?
you would have to change your query something like this: (this is not tested - just to show to construct query - you probably will need to adjust filter in allFile query (also you shouldn't filter by id, we will be chaning id in gatsby v2 so they won't contain paths)
export const query = graphql`
query BlurUpQuery {
heroAssets: allFile(filter: { absolutePath: { regex: "/testImage/" } }) {
edges {
node {
childImageSharp {
sizes(maxWidth: 600) {
...GatsbyImageSharpSizes_tracedSVG
}
}
}
}
}
}
`
Due to the high volume of issues, we're closing out older ones without recent activity. Please open a new issue if you need help!
Most helpful comment
you would have to change your query something like this: (this is not tested - just to show to construct query - you probably will need to adjust filter in
allFilequery (also you shouldn't filter byid, we will be chaning id in gatsby v2 so they won't contain paths)