rfcs icon indicating copy to clipboard operation
rfcs copied to clipboard

Exclude source/original image in sharp GraphQL image queries

Open jpavlicek opened this issue 6 years ago • 6 comments

Add a feature flag to not include the source image in srcset when using gatsy-plugin-sharp and gatsby-transformer-sharp.

jpavlicek avatar Jan 06 '19 18:01 jpavlicek

Overall I think this seems reasonable. Someone from @gatsbyjs/core will need to sign off, though.

jlengstorf avatar Jan 11 '19 04:01 jlengstorf

Why would you not want to include the original image?

KyleAMathews avatar Jan 11 '19 05:01 KyleAMathews

If you have an image with 15 megapixels or bigger and want to keep your deployment as lean as possible, just for performance while deploying – if you're using your image with a width of 800px there is no need to "give away" an image with a width of 5000px to everybody on the web. Or perhaps you got the picture from a photographer and you're only allowed to use it up to a specific size in web. So it could be both performance or licensing reasons.

jpavlicek avatar Jan 11 '19 10:01 jpavlicek

Maybe different approach to filter out very large images would be to specify cutoff threshold to not include images bigger than (for example) 2000px? We potentially could even set some defaults for this.

This would let users not worry about context and know if used images are actually big or not (especially if site would pull data from CMS and developer is not in charge of content)?

pieh avatar Jan 11 '19 18:01 pieh

Sorry for the late reply. I really think the threshold approach would be the perfect solution. Though I think the default should be without threshold. So we wouldn't have any change for existing users but extend it to have more control.

So I would propose either to have an option like threshold which applies both for max width and max height or a threshold for each width and height. For the sake of keeping it stupid and simple I'd prefer the threshold for both width and height.

jpavlicek avatar Jan 22 '19 07:01 jpavlicek

I'd agree that keeping behavior the same would be ideal for now. Maybe in the next major release we could set some guardrails up, though — seems like it would be good to save people from accidentally deploying 10MB images. 😅

jlengstorf avatar Jan 22 '19 16:01 jlengstorf