Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the data:base64 string to use with next/image? #244

Open
notflip opened this issue Dec 20, 2024 · 1 comment
Open

How to get the data:base64 string to use with next/image? #244

notflip opened this issue Dec 20, 2024 · 1 comment

Comments

@notflip
Copy link

notflip commented Dec 20, 2024

I'm trying to implement this package with next/image, however I think the blurhash string needs to be converted to a base64 string to work with next/image? This is my current code, which is not rendering the blurhash

    <Image
      src={`${media.url!}?${media.updatedAt}`} alt={`Image box alt`}
      width={1920}
      height={1080}
      className={imageClassName}
      sizes={sizes}
      style={{objectFit: "cover"}}
      quality={95}
      fill={fill}
      placeholder={media.blurhash ? "blur" : undefined}
      blurDataURL={media.blurhash || undefined}
    />

Thanks!

@ChillerPerser
Copy link

ChillerPerser commented Dec 21, 2024

As you mentioned do a convert from blurhash into a base64 string.

For example im using this (i dont know the source anymore, if anyone knows feel free to comment):
Gist

Its based on:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants