Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sample code showing off gatsby-image + image processing to query with GraphQL page #3589

Merged
merged 3 commits into from
Jan 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/docs/querying-with-graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,33 @@ Gatsby has rich support for processing images. Responsive images are a big part

Combined with a special Gatsby image component, [gatsby-image](/packages/gatsby-image/), you have a very powerful set of primatives for building sites with images.

This is what a component using `gatsby-image` looks like:

```jsx
import React from "react";
import Img from "gatsby-image";

export default ({ data }) => (
<div>
<h1>Hello gatsby-image</h1>
<Img resolutions={data.file.childImageSharp.resolutions} />
</div>
);

export const query = graphql`
query GatsbyImageSampleQuery {
file(relativePath: { eq: "blog/avatars/kyle-mathews.jpeg" }) {
childImageSharp {
# Specify the image processing specifications right in the query.
# Makes it trivial to update as your page's design changes.
resolutions(width: 125, height: 125) {
...GatsbyImageSharpResolutions
}
}
}
}
`;

See also the following blog posts:

* [Making Website Building Fun](/blog/2017-10-16-making-website-building-fun/)
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ plugins: [

## How to use

This is what a component using `gatsby-images` looks like.
This is what a component using `gatsby-image` looks like:

```jsx
import React from "react";
Expand All @@ -95,7 +95,7 @@ export const query = graphql`
query GatsbyImageSampleQuery {
file(relativePath: { eq: "blog/avatars/kyle-mathews.jpeg" }) {
childImageSharp {
# Specify the image processing steps right in the query
# Specify the image processing specifications right in the query.
# Makes it trivial to update as your page's design changes.
resolutions(width: 125, height: 125) {
...GatsbyImageSharpResolutions
Expand Down