next/future/image blur placeholder does not fill parent div
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Binaries:
Node: 14.17.3
npm: 8.19.1
Yarn: 1.22.4
pnpm: N/A
Relevant packages:
next: 12.3.1-canary.3
eslint-config-next: 12.2.5
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
The blur placeholder in next/future/image with fill=true is shown at the original image dimensions instead of filling the parent div (as the image does when loaded)
Expected Behavior
Same behaviour as next/image, that the placeholder fills the parent div
Above: next/image
Below: next/future/image
Link to reproduction
https://github.com/tiotdev/next-future-image-blur-fill-bug
To Reproduce
import Image from "next/image";
import FutureImage from "next/future/image";
export default function Home() {
return (
<>
<div
style={{
width: "100%",
height: "200px",
backgroundColor: "red",
position: "relative",
}}
>
<Image
src="https://img.travelfeed.io/jpphotography%2F20200609T140211386Z-reisen-127.jpg"
alt=""
blurDataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAIAAADwyuo0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAI0lEQVR4nGMINGf4/+3at/t7+2viGNQZGKbE69UlOSV5mgEAnuYKmizl818AAAAASUVORK5CYII="
placeholder="blur"
layout="fill"
objectFit="cover"
/>
</div>
<div
style={{
width: "100%",
height: "200px",
backgroundColor: "red",
position: "relative",
}}
>
<FutureImage
src="https://img.travelfeed.io/jpphotography%2F20200609T140211386Z-reisen-127.jpg"
alt=""
blurDataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAIAAADwyuo0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAI0lEQVR4nGMINGf4/+3at/t7+2viGNQZGKbE69UlOSV5mgEAnuYKmizl818AAAAASUVORK5CYII="
placeholder="blur"
fill
sizes="100vw"
style={{ objectFit: "cover" }}
/>
</div>
</>
);
}
Issue Analytics
- State:
- Created a year ago
- Reactions:9
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Next/Image Doesn't Fill Parent Div! - coffeeclass.io
A custom loader; Quality control; Placeholder image; and more! The NextImage component makes the lives of the website visiter much better, ...
Read more >NextJS Image component with fixed witdth and auto height
I have tried many different variations of this code but it will not work unless I define a fixed height on the parent...
Read more >next/image - Next.js
When blur , the blurDataURL property will be used as the placeholder. If src is an object from a static import and the...
Read more >Next.js image optimization techniques | Uploadcare Blog
Not so long ago, Next.js developers added an Image component to the ... Next can generate a blurred placeholder image automatically or let ......
Read more >Nextjs image optimization with examples - Refine Dev
Traditionally, images are added to web pages with the HTML img tag. ... in width and height to fill its parent element's width...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think this has something to do with the SVG that is wrapping the
blurDataURL
. When I disable JavaScript and I switch thebackground-url
out with my generated base64 low quality and blurred image, it places itself perfectly.Note: I am still experiencing this in next@13, using the now renamed
next/image
componentThe blurDataURL image is not respecting the
object-fit: cover
style (on either the next/imagestyle
orclassName
props). Rather the blurred image appears as if it were 'object-fit: contain '.The actual image that the blurDataURL is replaced with does respect the object-fit style properly though.