question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

next/future/image blur placeholder does not fill parent div

See original GitHub issue

Verify 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 futureImageBug

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:open
  • Created a year ago
  • Reactions:9
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
topaxicommented, Nov 28, 2022

I think this has something to do with the SVG that is wrapping the blurDataURL. When I disable JavaScript and I switch the background-url out with my generated base64 low quality and blurred image, it places itself perfectly.

1reaction
mcgrealifecommented, Oct 31, 2022

Note: I am still experiencing this in next@13, using the now renamed next/image component

The blurDataURL image is not respecting the object-fit: cover style (on either the next/image style or className 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found