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

Image stays blurred with lqip-loader #138

Open
jordanpunzalann opened this issue Mar 26, 2020 · 3 comments
Open

Image stays blurred with lqip-loader #138

jordanpunzalann opened this issue Mar 26, 2020 · 3 comments

Comments

@jordanpunzalann
Copy link

jordanpunzalann commented Mar 26, 2020

Hi there,

I just have an issue with using lqip-loader with this package. I have:

  1. enabled the next-optimised-images plugin in next.config.js file
  2. npm install lqip-loader
  3. added "?lqip" to my img src (i.e. <img src={require('../../images/hero.png?lqip')}/>

When I check to see the result the image is blurred, but it seems to remain that way. I have tried Chrome and FF, but they both give the same still blurred image. I have tried w/ other packages such as 'webp' and they work with next-optimised-images perfectly.

Any help would be greatly appreciated as I have been fiddling around with it for a few hours with no luck.

Thanks.

1

2

3

Blurred still image that does not optimise:
4

@akafaneh
Copy link

+1
I'm facing the same issue, it feels like there is a step we missed maybe, a way to replace the image once the big one loaded, but the docs are not clear on that and i've searched a lot and got nothing.

@kochie
Copy link

kochie commented May 5, 2020

Yes so when you use the lqip loader it will return a string that is just the base64 lqip image. You need to add the image later.

Example from a react component I made.

async function getImage(): Promise<void> {
    return new Promise((resolve, reject) => {
      try {
        if (imgRef.current) {
          imgRef.current.onload = (): void => {
            imgRef.current?.classList.add(imageStyle.sharpen)
            resolve()
          }
          imgRef.current.src = src
          imgRef.current.onanimationend = (): void =>
            imgRef.current?.classList.remove(
              imageStyle.blur,
              imageStyle.sharpen
            )
        } else {
          console.warn('imgRef does not have a current reference!')
        }
      } catch (error) {
        console.error(error)
        reject(error)
      }
    })
  }

@goncalogteixeira
Copy link

Can you please give more context? I also have an issue with this. Can you give an example of the usage of the component you shared?

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

4 participants