Skip to content

Conversation

@ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Feb 12, 2021

WIP: docs for plugin authors

rendered view

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Feb 12, 2021
Copy link
Contributor

@gillkyle gillkyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really good 🙂

I left a few suggestions that you're welcome to consider. I think a section at the end that links to places where this is implemented in other source plugins would be really helpful too.

}

// You could also calculate dominant color, and pass that as `backgroundColor`
// gatsby-plugin-sharp includes helpers that you can use to generate a tracedSVG or calculate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not exactly sure what these helpers are, maybe it could be possible to link to some docs/code (wherever it exists?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I need to document these!

@LekoArts LekoArts added topic: media Related to gatsby-plugin-image, or general image/media processing topics type: documentation An issue or pull request for improving or updating Gatsby's documentation and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Feb 15, 2021
Co-authored-by: Frederick Fogerty <[email protected]>
@ascorbic ascorbic marked this pull request as ready for review February 16, 2021 10:34
Copy link
Contributor

@laurieontech laurieontech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great job! I understand the two paths a lot better now. Left small edits and comments.

---

The [new Gatsby image plugin](https://www.gatsbyjs.com/docs/how-to/images-and-media/using-gatsby-plugin-image) includes React components for displaying images, and these can be used with data from plugins. The plugin handles all of the hard parts of displaying responsive images that follow best practices for performance. In fact we are confident that it is the fastest way to render images in React, as it can handle blur-up and lazy-loading before React hydration.
Support for these are available out of the box in `gatsby-transformer-sharp`, so if your plugin downloads images and processes them locally then your users can use the [`gatsbyImageData` resolver](https://www.gatsbyjs.com/docs/how-to/images-and-media/using-gatsby-plugin-image#dynamic-images). However, if your CDN can deliver images of multiple sizes with a URL-based API, then the plugin includes a toolkit to allow you to give your users the same great experience without needing to download the images locally. It also allows you to create components that display these images dynamically at runtime, without needing to add a GraphQL resolver.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these components?


There are three steps to add a basic `gatsbyImageData` resolver:

1. [Create the `generateImageSource` function](#create-the-generateimagesource-function)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might put this earlier to help give context? Not sold on that approach though.

Copy link
Contributor

@laurieontech laurieontech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is certainly ready to go in. Any smaller changes can be made later.

@ascorbic ascorbic merged commit 3f8399b into master Feb 17, 2021
@ascorbic ascorbic deleted the docs/image-plugin-toolkit branch February 17, 2021 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: media Related to gatsby-plugin-image, or general image/media processing topics type: documentation An issue or pull request for improving or updating Gatsby's documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants