alexlobera / gatsby-source-sanity-transform-images

Gatsby plugin
https://www.gatsbyjs.org/packages/gatsby-source-sanity-transform-images/
19 stars 7 forks source link

GraphQL Query has no support for downloading original-size images from Sanity #2

Closed rioam2 closed 4 years ago

rioam2 commented 4 years ago

Hi!

Thanks for creating this plugin :) After using it for a bit, I've noticed that when an image width is not specified, the image that is pulled from Sanity is only 600px:

https://github.com/reactgraphqlacademy/gatsby-source-sanity-transform-images/blob/f9a30f509fd37a4e84323b93f7be8abd00d3149e/src/gatsby-node.js#L10-L13

This limits the image size and quality before Gatsby-Image has a chance to make transformations based on 'maxWidth' on the fluid fragment.

I propose making the width query parameter optional, kind of like what you did for the height parameter here:

https://github.com/reactgraphqlacademy/gatsby-source-sanity-transform-images/blob/f9a30f509fd37a4e84323b93f7be8abd00d3149e/src/gatsby-node.js#L46-L49

This will cause the plugin to download an original resolution image from Sanity when a width is not manually provided.

I am happy to create a PR for this change if you think it would make a good addition to the plugin :) Let me know!

alexlobera commented 4 years ago

@rioam2 I think what you propose it's a more flexible solution, thanks for suggesting that and volunteering to implement. Please go ahead create the PR.

rioam2 commented 4 years ago

@alexlbr Thanks for following up! I've submitted/linked the PR 🙂