2.0.0 • Published 1 year ago

@gvrs/gatsby-transformer-blurhash v2.0.0

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
1 year ago

@gvrs/gatsby-transformer-blurhash

npm (scoped) NPM PRs Welcome

Generate BlurHash placeholders for images.

Configuration

// In your gatsby-config.js
module.exports = {
  plugins: [
    `gatsby-plugin-image`,
    `gatsby-plugin-sharp`,
    `gatsby-transformer-sharp`,
    `@gvrs/gatsby-transformer-blurhash`,
  ],
};

Usage example

Fetching data

imageSharp {
  gatsbyImageData(
    placeholder: NONE
  )
  blurHash(
    componentX: 3,
    componentY: 4,
    width: 32
  ) {
    base64Image
    hash
  }
}

Rendering

import { GatsbyImage } from "gatsby-plugin-image";

const Image = ({ gatsbyImageData, blurHash }) => (
  <GatsbyImage
    image={{
      ...gatsbyImageData,
      placeholder: {
        fallback: blurHash.base64Image,
      },
    }}
  />
);

Parameters

  • width (int, default: 32)
  • componentX (int, between 1 and 9, default: 3)
  • componentY (int, between 1 and 9, default: 4)

Returns

  • hash (string) — base 83 data returned by BlurHash
  • base64Image (string) — base 64 encoded image

Additional documentation

Prior art, inspiration

See also

2.0.0-next.2

1 year ago

2.0.0-next.1

1 year ago

2.0.0

1 year ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.3-next.1

2 years ago

1.0.2

2 years ago

1.0.2-next.1

2 years ago

1.0.1

2 years ago

1.0.1-next.1

2 years ago

1.0.0

2 years ago

1.0.0-next.2

2 years ago

1.0.0-next.1

2 years ago