Gatsby: base64 processing for images is always done

Created on 18 Nov 2020  路  3Comments  路  Source: gatsbyjs/gatsby

Description

base64 processing of images is always done even if the base64 field is omitted from the graphql query

Steps to reproduce

  1. run a graphql query that does not include the base64 field in childImageSharp, e.g:
childImageSharp {
  fluid(
    srcSetBreakpoints: [400, 600, 960, 1180, 1440]
    maxWidth: 1180
    quality: 100
  ) {
    aspectRatio
    presentationWidth
    sizes
    src
    srcSet
    srcSetWebp
    srcWebp
  }
}
  1. observe the base64 image (base64Image) is always generated in gatsby-plugin-sharp

reproducible example: https://github.com/redabacha/gatsby-base64-bug

you can debug gatsby develop and observe the described behaviour by adding a breakpoint somewhere in fluid/fixed depending on the query e.g. https://github.com/gatsbyjs/gatsby/blob/4d8ab789eca3ff8ba23645cc8890d137a3de258f/packages/gatsby-plugin-sharp/src/index.js#L556

Expected result

it should not generate the base64 image if it's not needed like traced svg behaviour

Actual result

it generated the base64 image despite being omitted in the query

Environment

  System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.15.0 - /var/folders/29/7y6db15d0rjd2gkzr9y0z6hh0000gq/T/yarn--1605707894869-0.2944966569145422/node
    Yarn: 1.22.5 - /var/folders/29/7y6db15d0rjd2gkzr9y0z6hh0000gq/T/yarn--1605707894869-0.2944966569145422/yarn
    npm: 6.14.8 - /usr/local/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 86.0.4240.198
    Edge: 86.0.622.69
    Firefox: 80.0.1
    Safari: 14.0.1
  npmPackages:
    gatsby: ^2.26.1 => 2.26.1 
    gatsby-plugin-sharp: ^2.8.0 => 2.8.0 
    gatsby-source-filesystem: ^2.5.0 => 2.5.0 
    gatsby-transformer-sharp: ^2.6.0 => 2.6.0 
stale? imagemedia bug

All 3 comments

This would be great to fix! Would you like to work on a PR?

This is fixed in the new resolver

Hiya!

This issue has gone quiet. Spooky quiet. 馃懟

We get a lot of issues, so we currently close issues after 60 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benstr picture benstr  路  3Comments

ferMartz picture ferMartz  路  3Comments

theduke picture theduke  路  3Comments

hobochild picture hobochild  路  3Comments

dustinhorton picture dustinhorton  路  3Comments