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

Default image placeholder blur persists in background for transparent .png images #2980

Open
benceruleanlu opened this issue Jul 19, 2024 · 12 comments
Labels

Comments

@benceruleanlu
Copy link

Expected Behaviour

A blurry image is used as a placeholder until the image loads.

Issue

The blurry image persists as a "background-image" for .png images with transparent backgrounds.

Example

image
image

@dimaMachina
Copy link
Collaborator

please share your image, to found a workaround

@benceruleanlu
Copy link
Author

The image I personally used is linked here: https://imgur.com/a/pqw6hNM.

With devtools, this is the generated placeholder:
image

@dimaMachina dimaMachina added the bug Something isn't working label Jul 20, 2024
@dimaMachina
Copy link
Collaborator

I don't think this is an issue with Nextra, this is an upstream issue from Next.js Image component

How would you like to fix it in Nextra without your workaround with the manual import of NextImage?

@dimaMachina dimaMachina added upstream and removed bug Something isn't working labels Jul 20, 2024
@benceruleanlu
Copy link
Author

In terms of fixing this problem in Nextra, I don't think anything should be done as the opinionated default inclusion of <Image> prop placeholder="blur" is usually a good choice for most images. If the developer has any issues, they should just use <Image> and not add the placeholder="blur" prop.

However, I disagree on this being purely an upstream issue with Next.js.

After testing the placeholder="blur" prop on an <Image> component inside a Nextra project, I can confirm that the blur does persist.

However, when testing the placeholder="blur" prop on an component inside a new Next.js project with create-next-app, the placeholder is briefly seen along with the regular image loaded in front, but the blurry placeholder is soon removed as everything finishes loading.

I'm not too familiar with Nextra's codebase, so I am not aware of how Nextra implemented the blur, or if they used <Image> with the prop placeholder="blur" at all.

image
image
image

@dimaMachina
Copy link
Collaborator

However, when testing the placeholder="blur" prop on an component inside a new Next.js project with create-next-app, the placeholder is briefly seen along with the regular image loaded in front, but the blurry placeholder is soon removed as everything finishes loading.

When I did repro in v3 with your image the blurry placeholder was soon removed as everything finished loading in Nextra too... curious why this didn't happen for you, could you try it in v3?

I'm not too familiar with Nextra's codebase, so I am not aware of how Nextra implemented the blur, or if they used with the prop placeholder="blur" at all.

Nextra just automatically import your images and add placeholder="blur" for you

hasBlur && {
type: 'mdxJsxAttribute',
name: 'placeholder',
value: 'blur'
},

@benceruleanlu
Copy link
Author

Not too sure how to build v3.

@dimaMachina
Copy link
Collaborator

check blog post https://the-guild.dev/blog/nextra-3

@dimaMachina
Copy link
Collaborator

below is repro in v2, is you have the same behaviour?

Screen.Recording.2024-07-20.at.17.41.28.mov

@benceruleanlu
Copy link
Author

This is what I see. Using Chrome 126.0.6478.182. Refreshed without cache.

import Image from 'next/image'
import testingImage from '../public/commonCharacteristicsOfGiftedLearners.png'

![testing image](/commonCharacteristicsOfGiftedLearners.png)

<Image src="/commonCharacteristicsOfGiftedLearners.png" alt="Diagram of common characteristics of gifted learners" width={816} height={403} style={{ margin: '1em auto' }} />

<Image src={testingImage} alt="Diagram of common characteristics of gifted learners" width={816} height={403} style={{ margin: '1em auto' }} placeholder="blur" />
2024-07-20.16-59-55.mp4

@benceruleanlu
Copy link
Author

I think this might just be a bad configuration on my system/project.

If it works at all then there shouldn't be an issue with the default setup.

@dimaMachina
Copy link
Collaborator

could you share your repo? so I could take a look

@benceruleanlu
Copy link
Author

could you share your repo? so I could take a look

Sure, this is the GitHub repo.

You have to manually re-add the image in markdown to maybe replicate the issue.

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

No branches or pull requests

2 participants