-
Notifications
You must be signed in to change notification settings - Fork 26k
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
[NEXT-943] Broken shimmer effect in next/image #47639
Comments
Hey @ArianHamdi, I agree there should be an option to use the placeholder url as-is, instead of adding a blur to it. I've had scenarios where I just want to show a stock background image without a blur but it's not possible without custom css. This is a simple enough feature to add and one I'm quite willing to do so, so I'm just wondering about how the prop interface can change to accommodate this.
@styfle would be great to hear your thoughts about this. |
Hey @ishaqibrahimbot, thanks for your attention.
I believe it would be better if the functionality of the prop and its name were consistent and aligned.
This is a good option that does not cause any breaking changes and avoids any confusion with the prop name. However, there is a concern if we decide to add more options to the In my opinion, the cleanest approach would be to add a What do you think about keeping |
The working deployment is using Next.js 12 which is basically Perhaps there is a way to continue using the SVG blur effect but still allow animation.
This could work although it wouldn't fix existing apps that upgrade from 12 to 13 and it would make the surface area of Maybe we could add support for something like |
@styfle yep I'm trying to debug the issue around the svg animation not kicking in. Will report here if I have a breakthrough and have figured out how to fix the svg animation. Also you're suggesting that we add the ability to directly pass placeholder image data in the |
👍 Supporting a Currently I had to fall back to a kludge with state, Example use case: <Image
width={200}
height={200}
placeholder={<Shimmer variant="image" />}
alt={"Keep it simple"}
src={src}
/> |
First of all I agree that we should rename the props at some point from: The last option makes more sense when we consider that a URL pointing to regular image can also be used as a placeholder (like Intermediate solution
@styfle I've tried to pass an animated SVG to the SVG we're generating but the animation won't work - it looks like passing animated SVG as data URI to the underlying I've looked into how it can be fixed and found a simple solution that won't introduce any breaking changes, but another When So for for the apps with a broken shimmer effect all that would have to be done to fix the issue is to replace If this approach seems sensible to you I already have a branch with the changes needed to make that work |
That sounds like you're suggesting The existing That's why my suggestion above was The implementation (pseudocode) might look like: const background = props.placeholder.startsWith('data:') ? props.placeholder : getBlurSvg(props.blurDataURL) |
If we want to go this route then we should probably do something like this: let background = null
if (placeholder !== "empty") {
background = props.placeholder === "blur" ? getBlurSvg(props.blurDataURL) : placeholder
} This will allow us to do: I'll submit a PR early next week |
We should not allow that usage. It must be a data uri because we don't want to incur another http request. The purpose of a placeholder is to ensure there is something there before the actual image loads. It should look like
|
Adds support for base64-encoded `placeholder`. Enables using placeholders without the "blur" effect. Fixes #47639 - [x] Add support for DataURL placeholder - [x] Add tests - [x] Update docs Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
Image optimization (next/image, next/legacy/image)
Link to the code that reproduces this issue
https://github.com/vercel/next.js/blob/canary/examples/image-component/pages/shimmer.tsx
To Reproduce
Open the following link: https://image-component.nextjs.gallery/shimmer. The shimmer effect is currently broken.
Describe the Bug
In the
next/image
component, the shimmer effect appears blurry compared to thenext/legacy/image
component where it works fine https://image-legacy-component.nextjs.gallery/shimmer. This is because next.js 13 always creates a blurry version of the blurDataUrl, which can be redundant and result in a broken shimmer effect.Expected Behavior
It would be helpful to have an option to use
blurDataUrl
without modification for cases where the shimmer effect is needed. Additionally, theplaceholder
prop can have more options beyond justempty
andblur
. Perhaps, we can renameblurDataUrl
toplaceholderDataUrl
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-943
The text was updated successfully, but these errors were encountered: