-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Add placeholder="blur" to Image component #18858
Comments
This will do: https://github.com/joe-bell/next-placeholder |
Hey friends, thanks for the mention of Just a heads up that I'm working on a new strategy which, from early testing, has shown to be faster than any existing "blur" placeholder option out there. It's pretty much done but I need to do some more testing and documentation before I release More than happy to collaborate with the Next.js core team to discuss further if this is urgent |
I think for now the easiest solution would be if the <Image
placeholder={() => <div style={{backgroundColor: 'grey'}} />} |
I've just launched Plaiceholder; the lastest iteration of You can use the "studio" UI or the open-source functions to create pure CSS blurred image placeholders ✨ |
This would be a really neat feature. I have been trying to implement some form of loading skeleton for an e-commerce project and I'm struggling to do it right with |
I moved to next/image, could see improvements in LCP. However, I do not have placeholder images now... |
Great to see this being worked on. The lack of progressive image loading is the first thing Next.js is inferior to Gatsby at, in their comparison. |
@dandv I agree completely. As a Gatsby convert, native progressive image loading is the one feature I miss from it. In the meantime, I am using @cyrilwanner's next-optimized-images with the |
@coopbri are you using both next/image with next-optimized-images fallback? If so, feel free to share some resources with the community. Thx! 🙂 |
If anyone's stuck creating an image placeholder in the meantime, there's a Next.js example over in the plaiceholder repo:
Hope this helps! |
@mnikolaus I am using both packages, but not in the way you probably expect (working together). Basically, I have one The ideal situation I was looking for was an image loaded with |
@coopbri I would expect it that way to work 🙂 Can you just share your next config of how you achieved that? Thanks! |
@mnikolaus Absolutely! I am actually just using similar code to the |
This is the image component implementation of the blurry placeholder as described in #24004. The matching server side implementation is currently planned. ## Feature - [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [x] Related issue #18858 - [x] Integration tests added (Documentation and telemetry to follow after server side is implemented)
This is the image component implementation of the blurry placeholder as described in vercel#24004. The matching server side implementation is currently planned. ## Feature - [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [x] Related issue vercel#18858 - [x] Integration tests added (Documentation and telemetry to follow after server side is implemented)
I noticed that the implementation in #25945 doesn't add any kind of scaling to hide the white edges that come about as a result of the blurring - plaiceholder suggest a |
This feature is available in Next.js 11! 🎉 Learn more: If you run into any bugs, please create a new issue with the steps to reproduce and we'll take a look, thanks! |
@styfle Cool! more and more new things are being achieved that further enrich Next.js. But I have a doubt to admit a skeleton or a custom component load is there an issue for this? |
You can use the |
The example shows a picture of the filesystem. Will there be an example of remote images with the blur effect? That would be helpful to see how that would be implemented |
For remote images, you could use Demo Code import * as React from "react";
import { InferGetStaticPropsType } from "next";
import Image from "next/image";
import { getPlaiceholder } from "plaiceholder";
export const getStaticProps = async () => {
const { base64, img } = await getPlaiceholder(
"https://images.unsplash.com/photo-1621961458348-f013d219b50c?auto=format&fit=crop&w=2850&q=80",
{ size: 10 }
);
return {
props: {
imageProps: {
...img,
blurDataURL: base64,
},
},
};
};
const ExamplePage: React.FC<InferGetStaticPropsType<typeof getStaticProps>> = ({
imageProps,
}) => <Image {...imageProps} placeholder="blur" />;
export default ExamplePage; cc @dohomi See also #26168 (comment) |
It was mentioned in Issue #18858 that we might add a `placeholder="skeleton"` but that didn't ship with Next.js 11 because it would likely need to handle additional config such as light mode / dark mode, speed, duration, etc. So this PR adds an example of `blurDataURL` usage with a nice shimmer animation (sometimes called a skeleton).
The blurred image does not take the styles (border-radius) of the component into account. |
It was mentioned in Issue vercel#18858 that we might add a `placeholder="skeleton"` but that didn't ship with Next.js 11 because it would likely need to handle additional config such as light mode / dark mode, speed, duration, etc. So this PR adds an example of `blurDataURL` usage with a nice shimmer animation (sometimes called a skeleton).
this is not usable with https://github.com/woltapp/blurhash , right? |
@duveborg that's correct |
Is there any way to apply styling to the blur image (P.E. resizemode)? |
Hi, @duveborg is possible if you use https://github.com/ivansevillaa/use-next-blurhash. You just need to pass the hash generated to the hook, and it will return the blurred image to pass to the Image Component. |
Is this not a good idea? It seemed like the obvious solution, so I just assumed it was the API. Was shocked to find it wanted a string of |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Today, Next.js shows an empty placeholder when using
loading="lazy"
(the default behavior).We would like to add a
placeholder="blur"
option that shows a low res, blurred image until the actual image has been loaded.The blurred placeholder must work with any loader value and ideally the image would be inlined as a Data URL instead of incurring an additional HTTP request.
We should also consider other placeholder options such as
placeholder="skeleton"
or a user-defined class.Prior Art
The text was updated successfully, but these errors were encountered: